Page 1 of 2
JavaScript redirection can be done in 3 ways
Posted: Wed Jun 13, 2007 12:10 pm
by blue-sky
JavaScript redirection can be done in 3 ways:
1) Alert Redirect:
Code: Select all
<html>
<script>
alert("This page has been moved to a new location. **** OK to be redirected.");
location = "http://www.yoursite.com";
</script>
</html>
2) Confirm and Redirect:
Code: Select all
<html>
<script>
if(confirm("This page has been moved to a new location. Would you like to be redirected"))
{
location = "http://www.yoursite.com";
}
else
{
history.back();
}
</script>
</html>
3) Stealth Redirect:
Code: Select all
<html>
<script>
location = "http://www.yoursite.com";
</script>
</html>
Posted: Wed Sep 12, 2007 6:47 pm
by Gyanu
no u r wrong it can b done in4 ways. The forth one is
[HTML]<meta http-equiv="Refresh" content="10;URL=yurpage" />[/HTML]
is it write?
Posted: Sun Sep 16, 2007 9:28 am
by Lixas
i guess that is ok

Posted: Sun Sep 16, 2007 3:53 pm
by Flipper3
Yes, those are all ways to do it except for the alert no matter what they do they will be redirected. And secondly, you need to have:
instead of:
And finally, it is best to not to use Javascript since there are quite a bit of users that disable Javascript.

Posted: Mon Sep 17, 2007 4:18 pm
by Lixas
if user is disabled JS, you can notice him by:
Code: Select all
<noscript>message for user when JavaScripts are disabled. HTML code is supported</noscript>
Posted: Mon Sep 17, 2007 8:32 pm
by Flipper3
Lixas wrote:if user is disabled JS, you can notice him by:
Code: Select all
<noscript>message for user when JavaScripts are disabled. HTML code is supported</noscript>
Yeah, but then only the USER knows....not you.
Plus, you should want to make your website work for everybody. That's what Google does.
redicted
Posted: Fri Jan 25, 2008 10:48 am
by Gebbo
Thanks for the tip i think i might use it for my site :P
Posted: Sat Jan 26, 2008 9:41 am
by Tails5
I use PHP redirecting usually, just [php]<?php Header("Location:
http://www.the.other/url/");?>[/php]
Posted: Tue Jan 29, 2008 3:25 pm
by Lixas
i guess it's the best way to redirect. but sometimes php is just not able to do that. so in this case JS will do the job
Posted: Tue Jan 29, 2008 9:01 pm
by Flipper3
Lixas wrote:i guess it's the best way to redirect. but sometimes php is just not able to do that. so in this case JS will do the job
In what cases is PHP not able to do that?