Jump to content

Trying to get ad code to refresh in div


Recommended Posts

I've been doing some searching, but I can't figure this out, as I don't know enough about JS.


I have found a tutorial that does this

<TITLE>Crunchify - Refresh Div without Reloading Page</TITLE>
<style type="text/css">
body {
<script type="text/javascript"
            function() {
                setInterval(function() {
                    var randomnumber = Math.floor(Math.random() * 100);
                            'I am getting refreshed every 3 seconds..! Random Number ==> '
                                    + randomnumber);
                }, 3000);
    <div id="show" align="center"></div>
    <div align="center">
            by <a href="http://crunchify.com">Crunchify.com</a>

But I don't know what exactly I can remove, what needs to stay (as far as the js), and where exactly I insert my ad code that is in a <script> tag of its own... but that also has a <noscript> tag as a fallback. While I understand I need to change the refresh from 3 secs, can someone help me take out the example JS code, and tell me where I would put my JS ad code? And do I simply remove the <script tags from my ad code, when inserting it into an area that is already between <script> tags?


Any help on this would be appreciated, thanks!

Link to comment
Share on other sites

Basically, you only need the following:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    setInterval(function() {
        //run the code to change your ad here...
    }, 3000);

Of course, the jQuery-specific code could also be removed...unless you're planning to use for more than just determining when a page has loaded.

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.