JohnnyDoomo Posted June 21, 2014 Share Posted June 21, 2014 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! Quote Link to comment https://forums.phpfreaks.com/topic/289236-trying-to-get-ad-code-to-refresh-in-div/ Share on other sites More sharing options...
cyberRobot Posted June 24, 2014 Share Posted June 24, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/289236-trying-to-get-ad-code-to-refresh-in-div/#findComment-1483134 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.