Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Random Redirect and Delay?
Old 11-12-2006, 10:47 AM Random Redirect and Delay?
Menard's Avatar
Average Talker

Posts: 27
Trades: 0
I have been searching for a JavaScipt to perform a specific function without any luck. I have found scripts for a redirection to a random site, but no delay.

What I am trying to accomplish is, after the visitor has clicked on a link they will be taken to a page which will then redirect then to a randomly selected site. However, I want to delay them on the page for a few seconds.

Can anyone recommend a script, or a way I can do this?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Menard is offline
Reply With Quote
View Public Profile Visit Menard's homepage!
 
 
Register now for full access!
Old 11-13-2006, 09:52 PM Re: Random Redirect and Delay?
Extreme Talker

Posts: 246
Trades: 3
You can use setTimeout in JavaScript to 'delay' or 'pause', but you may want to use the following in HTML (not JavaScript)

The following example will wait 3 seconds, then redirect the browser to http://www.webmaster-talk.com
HTML Code:
<META HTTP-EQUIV="Refresh" CONTENT="3;URL=http://www.webmaster-talk.com">
This is assuming, of course, that you can insert the random URL into the code above.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by CouponGuy; 11-13-2006 at 09:54 PM..
CouponGuy is offline
Reply With Quote
View Public Profile
 
Old 11-13-2006, 10:40 PM Re: Random Redirect and Delay?
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Using CouponGuy's idea, I played around and came up with a following solution. The script has to reside inside the html header for it to work properly.

HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <title>Random JS Page Jump</title>
  <script type="text/javascript" language="javascript">
  <!--// Random JS Page Jump Code
    
    var jumpTo = new Array();
    
    // Define possible url jumps
    jumpTo[0] = 'http://www.webmaster-talk.com';
    jumpTo[1] = 'http://www.google.com';
    jumpTo[2] = 'http://www.apple.com';
    jumpTo[3] = 'http://www.microsoft.com';
    
    // Define random function
    function getRandom() {
      return Math.floor(Math.random() * jumpTo.length);
    }
    
    // Output meta refresh tag
    javascript: document.write('<META HTTP-EQUIV="Refresh" CONTENT="3;URL=' + jumpTo[getRandom()] + '">');
    
  //-->
  </script>
  </head>
  <body>
    Random JS Page Jump
  </body>
</html>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 11-15-2006, 04:19 PM Re: Random Redirect and Delay?
Menard's Avatar
Average Talker

Posts: 27
Trades: 0
Awesome! Thank you for providing that. I'll let you know how it works for me.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Menard is offline
Reply With Quote
View Public Profile Visit Menard's homepage!
 
Reply     « Reply to Random Redirect and Delay?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13557 seconds with 12 queries