Jump to content

Trying to get ad code to refresh in div


JohnnyDoomo

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

<HTML>
<HEAD>
<TITLE>Crunchify - Refresh Div without Reloading Page</TITLE>
 
<style type="text/css">
body {
    background-image:
        url('http://cdn3.crunchify.com/wp-content/uploads/2013/03/Crunchify.bg_.300.png');
}
</style>
<script type="text/javascript"
    src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
    $(document).ready(
            function() {
                setInterval(function() {
                    var randomnumber = Math.floor(Math.random() * 100);
                    $('#show').text(
                            'I am getting refreshed every 3 seconds..! Random Number ==> '
                                    + randomnumber);
                }, 3000);
            });
</script>
 
</HEAD>
<BODY>
    <br>
    <br>
    <div id="show" align="center"></div>
 
    <div align="center">
        <p>
            by <a href="http://crunchify.com">Crunchify.com</a>
        </p>
    </div>
</BODY>
</HTML>

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">
//ONCE THE PAGE IS LOADED
$(document).ready(function() {
    //SET TIMER
    setInterval(function() {
        //run the code to change your ad here...
   
    }, 3000);
});
</script>

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. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
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.