Redirect WEB PAGE . . .

I

IveCal

Hello, I'm new in javascript. I hava a snippet below. This code will
redirect my current web page to http://www.test123test1111.com . . .
But I want to specify the number of seconds before it is redirected.
May I know how to do this? (As much as possible, meta tags should not
be used.) Please do reply. Thanks a lot.

<SCRIPT LANGUAGE="JavaScript">
<!--
window.location="http://www.test123test1111.com";
// -->
</script>
 
E

Evertjan.

IveCal wrote on 18 mei 2006 in comp.lang.javascript:
Hello, I'm new in javascript. I hava a snippet below. This code will
redirect my current web page to http://www.test123test1111.com . . .
But I want to specify the number of seconds before it is redirected.
May I know how to do this? (As much as possible,
meta tags should not be used.)

Why not, <meta refresh ... is the logical solution!

Or is this a school assignment?
<SCRIPT LANGUAGE="JavaScript">

do not use language="JavaScript" anymore

do not use <!-- anymore

do not use // --> anymore
</script>


<script type='text/javascript'>

function redir(){
window.location.href="http://www.test123test1111.com";
};

setTimeout('redir()',3*1000)

</script>
 
B

Botan Guner

IveCal said:
Hello, I'm new in javascript. I hava a snippet below. This code will
redirect my current web page to http://www.test123test1111.com . . .
But I want to specify the number of seconds before it is redirected.
May I know how to do this? (As much as possible, meta tags should not
be used.) Please do reply. Thanks a lot.

<SCRIPT LANGUAGE="JavaScript">
<!--
window.location="http://www.test123test1111.com";
// -->
</script>

Put this in your document's body,

<div id="lbl">&nbsp;</div>
<script language="javascript" type="text/javascript">
<!--
var sec=5;
var lbl=document.getElementById("lbl");
function goTo() {
lbl.innerHTML=sec + " to go...";
sec--;
if(sec==-1) {
lbl.innerHTML="Loading...";
window.location="http://www.test123test1111.com";
} else {
setTimeout("goTo()",1000);
}
}
goTo();
// -->
</script>
 
P

pegasusflightresources

IveCal said:
Hello, I'm new in javascript. I hava a snippet below. This code will
redirect my current web page to http://www.test123test1111.com . . .
But I want to specify the number of seconds before it is redirected.
May I know how to do this? (As much as possible, meta tags should not
be used.) Please do reply. Thanks a lot.

<SCRIPT LANGUAGE="JavaScript">
<!--
window.location="http://www.test123test1111.com";
// -->
</script>

Just use a simple setTimeout. The following one makes a 4 second wait
(setTimeout uses the time parameter in milliseconds).

<script type="text/javascript">
//never use that<!-- anymore
setTimeout("redirect()", 4000);
function redirect()
{
//don't use window.location anymore, it is considered deprecated to
most people
location.href = "http://www.test123test1111.com";
}
</script>

I have the honor to remain your most humble and Ob't Sv't in our war
against the King.
 
V

VK

//don't use window.location anymore, it is considered deprecated to
most people
location.href = "http://www.test123test1111.com";

Eh? And what do you think you are using above? It's just a shortcut of
window.location.href
same as setTimeout or alert are shortcuts of
window.setTimeout and window.alert

You were thinking of document.location which is indeed deprecated now.
Historically (JavaScript 1.0) window.location was read/write and
document.location read-only, but later this schema was simplified in
favor of window.location only.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Thu, 18
May 2006 07:40:14 remote, seen in Evertjan.
IveCal wrote on 18 mei 2006 in comp.lang.javascript:

Why not, <meta refresh ... is the logical solution!

FYI, meta refresh is deprecated though I forget why. I use it myself,
because alternatives other than javascript are not available to me and
script may not be enabled.

function redir(){
window.location.href="http://www.test123test1111.com";
};

setTimeout('redir()',3*1000)

or just
setTimeout('window.location.href="http://www.test123test1111.com"', 3000)
?
 
R

Randy Webb

Dr John Stockton said the following on 5/18/2006 5:50 PM:
JRS: In article <[email protected]>, dated Thu, 18
May 2006 07:40:14 remote, seen in Evertjan.


FYI, meta refresh is deprecated though I forget why. I use it myself,
because alternatives other than javascript are not available to me and
script may not be enabled.

How can something be deprecated that was never a standard to start with?

FYI as well: IE6 allows the explicit disabling of the META Refresh.
 
E

Evertjan.

Randy Webb wrote on 19 mei 2006 in comp.lang.javascript:
How can something be deprecated that was never a standard to start with?

FYI as well: IE6 allows the explicit disabling of the META Refresh.

Javascript likewize!

If users want to cripple their browsers,
accommodating them with "gracefull degrading"
will only confirm them in their silly quest.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top