Results 1 to 2 of 2

Thread: Modify URL opening code

  1. #1
    Join Date
    Mar 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Modify URL opening code

    Hi,

    First post here as my javascript knowledge is abysmal. Hoping you can help.

    I have the code below to open a web page in the array every 60 seconds.
    However what I would like it to actually do is open each page for 60 seconds then close it.
    Code:
    
    
      	var myPages=["http://www.google.com", "http://www.yahoo.co.uk", "http://www.bing.co.uk"],
          i = -1;
    
      	(function f(){
          i = (i + 1) % myPages.length;
          wo=window.open(myPages[i]);
          setTimeout(f, 60000);
    
       })();
    Last edited by keyboard; 03-17-2014 at 09:37 PM. Reason: Format: Fixed Code Tags [code][/code]

  2. #2
    Join Date
    Mar 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    // I replied to this thread some days ago but my reply was not posted (may be I am a new user and dynamicdrive don't trust me much)
    // Here is the code
    Code:
    <html>
    	<head>
    	<script type = "text/javascript">
    			var myTimer;
    			var myPages = ["http://www.google.com","http://www.yahoo.com", "http://alexa.com"]
    			var counter = 0;
    			timer(true);
    			function timer(bool){
    			//alert(bool);
    				if (bool) {
    				myTimer = setInterval(function(){
    				handleInterval();
    				},10000);
    				}else{
    				clearInterval(myTimer);
    				}
    			}
    			
    			function handleInterval(){
    			if (counter >= myPages.length) counter = 0;
    			var myDoc = window.open(myPages[counter]);
    			counter++;
    			setTimeout(function(){myDoc.close()},10000);
    			
    			}
    	</script>
    	</head>
    
    	<body>
    
    	<button onclick = "timer(true)">Start Timer</button>
    	<button onclick = "timer(false)">Stop Timer</button>
    	
    	
    	</body>
    </html>
    //Just put as many websites in array as so want
    // It is currently set to 10 sec. You can change the time interval
    //Please wait for 10 seconds. Each site will open and close automatically

Similar Threads

  1. Drop-down Document Viewer -- modify code
    By crafix in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 09-27-2010, 09:40 PM
  2. Modify autoresponder code
    By shelley in forum Looking for such a script or service
    Replies: 0
    Last Post: 04-22-2008, 10:17 PM
  3. modify a code
    By masquerade in forum JavaScript
    Replies: 10
    Last Post: 04-27-2007, 10:15 AM
  4. Usage Terms (Modify Code)
    By Zubi in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 11-07-2006, 09:44 PM
  5. Modify simple code
    By Peppy in forum HTML
    Replies: 2
    Last Post: 08-18-2005, 05:19 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •