473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Redirect WEB PAGE . . .

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>

May 18 '06 #1
8 2270
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
window.location="http://www.test123test1111.com";
// -->
do not use // --> anymore
</script>

<script type='text/javascript'>

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

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

</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 18 '06 #2

IveCal wrote:
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>

May 18 '06 #3

IveCal wrote:
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.

--
Patrick Reilly
1st Coy.
Colonel Seth Warner's Regiment

May 18 '06 #4
Also, this script should be in the body.

May 18 '06 #5
VK

pe********************@gmail.com wrote:
//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.

May 18 '06 #6
JRS: In article <Xn********************@194.109.133.242>, dated Thu, 18
May 2006 07:40:14 remote, seen in news:comp.lang.javascript, Evertjan.
<ex**************@interxnl.net> posted :
IveCal wrote on 18 mei 2006 in comp.lang.javascript:
meta tags should not be used.)


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

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
May 18 '06 #7
Dr John Stockton said the following on 5/18/2006 5:50 PM:
JRS: In article <Xn********************@194.109.133.242>, dated Thu, 18
May 2006 07:40:14 remote, seen in news:comp.lang.javascript, Evertjan.
<ex**************@interxnl.net> posted :
IveCal wrote on 18 mei 2006 in comp.lang.javascript:

meta tags should not be used.)

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.


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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 19 '06 #8
Randy Webb wrote on 19 mei 2006 in comp.lang.javascript:
meta tags should not be used.)
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.


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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 19 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Bob Garbados | last post by:
forgive my ignorance, as I'm new to php coming from a ms background... If I create a page named redirect.php and it's only content is: <?php header("Location: http://www.google.com"); ?>...
7
by: Donna Hawkins | last post by:
I want to use javascript to redirect to a URL which has been passed as a variable (in php). I have searched but cannot find any solution. I think this code is a basic redirect: <script...
3
by: Justin | last post by:
Hi, Im confused here over the usage of Response.Redirect and Server.Transfer. I used frameset for my work, what are the proper usages of the two methods that seems working similar.. The...
6
by: Sam | last post by:
I have some issues with HTTP Headers and I was hoping for some pointers or references to good articles. Here is the problem. I have 6 .aspx pages, each page contains a common .ascx. This ascx...
13
by: Tim | last post by:
Hello, Is there a way to "cancel" a response.Redirect? For example, in the code below, could I insert anything in the Catch statement that would cancel the redirect and resume flow after the...
4
by: bnob | last post by:
In a Button clik event I have this code at the end of the event Response.Redirect("Page.aspx") But in this event I must show a message before redirect to the Page.aspx. I use to show Message...
5
by: Alan Silver | last post by:
Hello, I have a page that is supposed to do some checking, and if OK, set a session variable before redirecting to another page. The following code is a simplified version, I have hard-coded the...
5
by: venner | last post by:
I'm having an issue with an ASP.NET website after upgrading to ASP.NET 2.0. The website makes use of a central authentication service (CAS) provided at the university I work for. Each page checks...
8
by: Darrel | last post by:
I'm helping convert a 300+ page .html site into an ASP.net site. The client wants to set up 301 redirects for all of the old html pages. I've used ISAPI for this type of thing in the past, as it...
1
by: gnawz | last post by:
Hi guys, I have a couple of php files that perform various tasks. I will use fields in my system and provide code as well I need help as follows: My database contains the fields Category...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.