...

View Full Version : Set Time out to redirect to index.



hcrosex3
11-19-2012, 06:26 PM
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?



<!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>

Philip M
11-19-2012, 06:47 PM
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.

minder
11-19-2012, 10:43 PM
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.
(http://www.w3schools.com/jsref/met_win_settimeout.asp)
Therefore a better way to do it is


<script type="text/javascript">
function doThis(){
alert('Hello World');
}
setTimeout(doThis,5000);
</script>

Philip M
11-20-2012, 09:15 AM
@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.
(http://www.w3schools.com/jsref/met_win_settimeout.asp)
Therefore a better way to do it is


<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. :D 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.

minder
11-20-2012, 11:14 AM
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 (https://developer.mozilla.org/en-US/docs/DOM/window.setTimeout) say


Passing a string instead of a function to setTimeout() suffers from the same hazards as using eval (https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/eval#Don.27t_use_eval.21).
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() (https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/eval#Don%27t_use_eval%21))

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.

Philip M
11-20-2012, 12:01 PM
I didn't mention extra processing time at all.

I said

The guys over at Mozilla (https://developer.mozilla.org/en-US/docs/DOM/window.setTimeout) 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.

minder
11-20-2012, 12:10 PM
“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 ;)

Philip M
11-20-2012, 02:13 PM
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. :p

minder
11-20-2012, 09:55 PM
Don't forget to take your Barmidon tablets first. :) They may help you to improve. :p

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 :)

Philip M
11-20-2012, 10:01 PM
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.

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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum