Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    32
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Set Time out to redirect to index.

    i currently have this script that redirects after timeout back to the previous page. How can I set it go to a specific page (index.html)? Also is it possible to show a countdown of the timeout timer on the page?


    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html lang="en"><head><title>404 - Page Not Found</title>
    
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    
    <meta name="revisit-after" content="37 days">
    <meta name="robots" content="INDEX, NOFOLLOW">
    <meta name="keywords" content="404, not found, page not found, error, errors, server error">
    <meta name="description" content="Ugh, 404 - dude, that does _NOT_ compute.">
    
    <meta http-equiv="Imagetoolbar" content="no"> 
    
    <script>
    <!--
    if (top.location != self.location) top.location.replace(self.location);
    //-->
    </script>
    
    <style>
    <!--
    body    { overflow-Y:auto; }
    a	 { text-decoration:none; }
    -->
    </style></head>
    
    
    <body topmargin="9" leftmargin="11" scroll="auto" onload="typeout(); window.defaultStatus=''; return true" bgcolor="black" marginheight="9" marginwidth="11" text="silver">
    
    <!--<div id="404" align=center><font size=7 color="#000099">404</font></div>-->
    <layer id="talkyNS4"></layer><div id="talky"><font color="silver" face="fixedsys, terminal, system, liquidcrystal, led real, joystix, cosmic alien, westminster, glitch1, monospace" size="3">C:\\ROSE&gt; Hey I'M TRYING TO TALK HERE! Did I ever tell you about the<br>C:\&gt;(abort)<br><br><font color="#33cc00">RETURNING TO PREVIOUS PAGE...</font><br><br><font color="silver">C:\\ROSE&gt; DAMMIT!&nbsp;<big><big><font color="black">.</font></big></big><big> DARN IT!&nbsp;&nbsp;&nbsp;<big>DARN IT!!</big></big></font><br></font></div>
    
    <noscript>
    <pre><font face="fixedsys, terminal, system, liquidcrystal, led real,
    joystix, cosmic alien, westminster, glitch1, monospace"
    size=3>C:\\ROSE> query result: 404 - error
    C:\\ROSE> Ugh, 404 - that does _NOT_ compute.
    C:\\ROSE> Page not found, dude. Well that just makes my day.
    C:\\ROSE> You know I spend all my time  writing scripts,
    C:\\ROSE> spitting out web-pages, and now THIS.
    C:\\ROSE> So when is that webmaster gonna come in here
    C:\\ROSE> and fix up all these broken links?
    C:\\ROSE> And hey - YOU! Big Cheese with the mouse:
    C:\\ROSE> if you typed in the URL, check you're spelling!
    C:\\ROSE> Oops, I mean check your spelling!!
    C:\\ROSE> Geez, it's no wonder I have an attitude.
    C:\\ROSE> You know some days I feel like I could just break down
    C:\\ROSE> and crash. That's it. Kaput. Bye-Bye. Gone to sleep.
    </font></pre>
    </noscript>
    
    <script>
    <!--Inspired by Darcy Boucher 
    runon = new Array
    (
    " C:\\> query result: error - 404<br>",
    
    " C:\\ROSE> Ugh, 404. That does _NOT_ compute.<br>",
    
    " C:\\ROSE> Well that just makes my day. Page not found, dude.<br>",
    
    " C:\\ROSE> You know I spend all my time writing scripts,",
    " C:\\ROSE> spitting out web-pages, and now THIS.<br>",
    
    " C:\\ROSE> So when is that webmaster gonna come in here",
    " C:\\ROSE> and fix up all these broken links?<br>",
    
    " C:\\ROSE> Geez it's no wonder I have an attitude.<br>",
    
    " C:\\ROSE> And hey - YOU! Big Cheese with the mouse:",
    " C:\\ROSE> if you typed in the URL, check you're spelling!",
    " C:\\ROSE> Oops, I mean check your spelling!!<br>",
    
    " C:\\ROSE> Hey, you still there? Good.",
    " C:\\ROSE> You know some days I feel like I could just break down",
    "*C:\\ROSE> and crash. That's it. Kaput. Bye-Bye. Gone to sleep.<br>",
    
    " C:\\ROSE> Heheheh... Scared you didn't I? I love playing little jokes",
    " C:\\ROSE> like that. But boy the things I have to put up with - I could",
    " C:\\ROSE> go on and on and hey! Did I ever tell you about the time that",
    " C:\\>(abort)<br>",
    
    "%<a href='javascript:void(0)' onMouseover='flagged(\"%\"); window.status=defaultStatus; return true' style='text-decoration:none' hideFocus><font color='#33CC00'>RETURN TO PREVIOUS PAGE...</font></a>",
    " C:\\ROSE> No wait! Don't click on the link yet. Did I ever tell you",
    " C:\\ROSE> about the",
    " C:\\>(abort)<br>",
    
    "%<a href='javascript:void(0)' onMouseover='window.status=defaultStatus; return true' onMousedown='flagged(\"%\")' style='text-decoration:none' onFocus='if(this.blur)this.blur();' hideFocus><font color='#33CC00'>RETURN TO PREVIOUS PAGE...</font></a>",
    " C:\\ROSE> Hey I'M TRYING TO TALK HERE! Did I ever tell you about the",
    //" C:\\ROSE> Hey I'M TRYING TO TALK HERE!",
    //"C:\\ROSE> Did I ever tell you about the",
    " C:\\>(abort)<br>",
    
    " <font color='#33CC00'>RETURNING TO PREVIOUS PAGE...</font><br>",
    "&<font color=silver>C:\\ROSE> UGGHHH!&nbsp;<big><big><font color=black>.</font></big></big>",
    "&<big>DARN IT!&nbsp;&nbsp;&nbsp;",
    "&<big>DARN IT!!</big></big></font>"//kluge font
    )
    
    OP	= (navigator.userAgent.indexOf("pera") != -1)
    IE	= document.all && !OP
    NS4 = document.layers
    gebi= (document.getElementById && !document.all)
    ihtml= document.body && (typeof document.body.innerHTML != "undefined")
    
    //preserve order!
    ramble	= (NS4)?document.talkyNS4.document :(!ihtml)?document :(IE)?document.all.talky :document.getElementById("talky")
    fonttag	= "<font face='fixedsys, terminal, system, liquidcrystal, led real, joystix, cosmic alien, westminster, glitch1, monospace' size=3 color=silver>"
    preform	= fonttag
    
    //flag=false
    if (NS4)
    {
    document.captureEvents(Event.MOUSEMOVE);
    document.captureEvents(Event.KEYDOWN);//nograb ALT
    }
    //document.onmousemove = flagged
    document.onkeydown = flagged
    function flagged(hand)
    {
    if (flag)
    {
    base = 600
    typeout()
    }
    
    if (hand && (hand == "%"))
    {
    preform = fonttag
    base = 600
    typeout()
    }
    }
    
    line = 0
    base = 1800
    function typeout()
    {
    document.onmousemove = null//kill OP6 multitrigs
    flag = false
    
    stripline = runon[line].substring(1, runon[line].length)
    
    if (ihtml) ramble.innerHTML = preform+stripline+ "<br></font>";
    else{
    if (!NS4) ramble.writeln("<body bgcolor=black>");
    
    ramble.writeln(preform+stripline+ "<br></font>")
    
    if (!NS4) ramble.writeln("</body>");
    ramble.close()
    }
    preform = preform+stripline+ ((runon[line].charAt(0) == "&")?"" :"<br>")
    
    if (line < runon.length-1)
    {
    if	 (runon[line].charAt(0) == "*"){	flag = true; document.onmousemove = flagged }
    else if (runon[line].charAt(0) == "%")	flag = false;
    else{
    wait = (runon[line].lastIndexOf("<br>") != -1)?base :50
    base = base + 200
    setTimeout("typeout()", wait)
    }
    line = line+1
    }
    else if (self.history.length > 0) setTimeout("self.history.back(1)", 425);
    else if (self.close) { opener = self; setTimeout("self.close()", 425); }
    }
    //document.onload = typeout();
    //-->
    </script>
    <!--0408220511-->
    </body></html>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,173
    Thanks
    203
    Thanked 2,549 Times in 2,527 Posts
    This is terribly ancient code. Netscape 4 is long one with Nineveh and Tyre.
    The <!-- and //--> comment (hiding) tags have not been necessary since IE3 (i.e. since September 1997). If you see these in some published script it is a warning that you are looking at ancient and perhaps unreliable code.

    setTimeout("window.location.href = 'myindexpage.html' ", 425);

    It is naturally possible to show a timer on the page - try using the search feature of this forum for (many) examples. But hardly for 425 milliseconds.


    Quizmaster: Which Israeli Prime Minister was born Golda Mabovitz in 1898?
    Contestant: Benjamin Disraeli.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Banned
    Join Date
    Oct 2012
    Posts
    81
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Philip M View Post
    setTimeout("window.location.href = 'myindexpage.html' ", 425);
    @OP

    That is generally accepted as a bad way of running javascript via setTimeout or setInterval because javascript has to then "eval" the string before running it.

    setTimeout and setInterval both accept references to functions or anonymous functions as inputs. Have a look at the explanation/example at w3schools.

    Therefore a better way to do it is

    Code:
    <script type="text/javascript">
                function doThis(){
                    alert('Hello World');
                }
                setTimeout(doThis,5000); 
    </script>
    Last edited by minder; 11-19-2012 at 09:48 PM.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,173
    Thanks
    203
    Thanked 2,549 Times in 2,527 Posts
    Quote Originally Posted by minder View Post
    @OP

    That is generally accepted as a bad way of running javascript via setTimeout or setInterval because javascript has to then "eval" the string before running it.

    setTimeout and setInterval both accept references to functions or anonymous functions as inputs. Have a look at the explanation/example at w3schools.

    Therefore a better way to do it is

    Code:
    <script type="text/javascript">
                function doThis(){
                    alert('Hello World');
                }
                setTimeout(doThis,5000); 
    </script>
    Take no notice of Minder (nee bullant) who can only hope to improve. He is always seeking to start a pointless argument. In this context where the call is once only any additional time to process is not discernable. There is no advantage in using an anonymous function here.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #5
    Banned
    Join Date
    Oct 2012
    Posts
    81
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Philip M View Post
    In this context where the call is once only any additional time to process is not discernable. There is no advantage in using an anonymous function here.
    I didn't mention extra processing time at all.

    I said

    That is generally accepted as a bad way of running javascript via setTimeout or setInterval because javascript has to then "eval" the string before running it.
    The guys over at Mozilla say

    Passing a string instead of a function to setTimeout() suffers from the same hazards as using eval.
    and
    code in the alternate syntax, is a string of code you want to execute after delay milliseconds (using this syntax is not recommended for the same reasons as using eval())
    If you disagree with them that's fine, but then why not tell them why it should be ok for them to pass a string to setTimeout/setInterval and see if they laugh at you as well.
    Last edited by minder; 11-20-2012 at 10:20 AM.

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,173
    Thanks
    203
    Thanked 2,549 Times in 2,527 Posts
    Quote Originally Posted by minder View Post
    I didn't mention extra processing time at all.

    I said

    The guys over at Mozilla say


    and


    If you disagree with them that's fine, but then why not tell them why it should be ok for them to pass a string to setTimeout/setInterval and see if they laugh at you as well.
    So what is your contrived objection then?

    “Overwhelmingly [eval is] trivialized, misused, and outright condemned by most JavaScript programmers but by looking at the work of some of the best coders you can see that , when used appropriately [it] allows for the creation of some fantastic pieces of code that wouldn’t be possible otherwise” -John Resig in Secrets of the JavaScript Ninja

    Remember, your status around here is that you can only hope to improve (which is, I agree, better than "Notorious around these parts" which you managed to achieve in your last incarnation as iBall).

    As I have often said before, you are not liked, so you are not respected. And because you are not respected your opinions are considered worthless.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #7
    Banned
    Join Date
    Oct 2012
    Posts
    81
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Philip M View Post

    “Overwhelmingly [eval is] trivialized, misused, and outright condemned by most JavaScript programmers .....” -John Resig in Secrets of the JavaScript Ninja
    So even he said it is outright condemned by most JavaScript programmers which is in agreement with what I said:

    That is generally accepted as a bad way of running javascript via setTimeout or setInterval because javascript has to then "eval" the string before running it.
    and what Mozilla say in the link I posted.

    If you're in the group that do not condem it that's fine, but you should be telling the guys over at Mozilla and see if they still laugh at you because I couldn't care less what you think. Like I said, being retired gives me the freedom to not have to put up with people telling me how to do things and so I can now go do what I think is best without considering what you or anyone else thinks

    I'll pass a copy of your post to the guys over at Mozilla for you
    Last edited by minder; 11-20-2012 at 11:15 AM.

  • #8
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,173
    Thanks
    203
    Thanked 2,549 Times in 2,527 Posts
    Quote Originally Posted by minder View Post
    I'll pass a copy of your post to the guys over at Mozilla for you
    Don't forget to take your Barmidon tablets first. They may help you to improve.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #9
    Banned
    Join Date
    Oct 2012
    Posts
    81
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Philip M View Post
    Don't forget to take your Barmidon tablets first. They may help you to improve.
    Haha

    When I see someone lower themselves to their knees and resort to attempts at immature insults I know I have won because they then obviously have nothing left to try to refute my previous arguments to support my case/view and in this case, Mozilla's as well.

    Even your last attempt to refute my argument ended up supporting what Mozilla are saying as I showed before

    So chalk one up for the mindster. Score: Minder 1, philip_m 0

    See you around and better luck next time

  • #10
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,173
    Thanks
    203
    Thanked 2,549 Times in 2,527 Posts
    Quote Originally Posted by minder View Post
    See you around and better luck next time
    No, you will soon be chucked out from Coding Forums again as you have been many times before.
    You already have one infraction. Two more and it's curtains. I'm betting you will be gone by Christmas.

    Edit: Oh dear, wrong again! That was a gross overestimate! Minder has been banned within hours of this post! Blessings upon you, Super Moderator firepages! But like a dog with fleas he will doubtless be back.
    Last edited by Philip M; 11-21-2012 at 07:51 AM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Posting Permissions

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