By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,379 Members | 1,748 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,379 IT Pros & Developers. It's quick & easy.

redirects w/ js

P: n/a
I have a site with PHP code that I need to have a js function to
redirect to another page or site. I am just trying to learn JS and need
a starting palce. Would this be difficult?

Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Magic-chef wrote:
I have a site with PHP code that I need to have a js function to
redirect to another page or site. I am just trying to learn JS and need
a starting palce. Would this be difficult?


Difficult, no, just set a new value for the window.location object.

But its probably the wrong way to do things, redirection using JavaScript is
almost always suboptimal compared to redirection using http (with a header
you can set using PHP) or even HTML (with the ugly meta redirect thing).
About the only time when redirecting using JS is apropriate is as part of a
test for JavaScript (and then only when the code can't be made to
gracefully degrade[1] so alternatives have to be provided).
[1] Rare, very rare. At least when an alternative can be provided.

--
David Dorward http://david.us-lot.org/
Redesign in progress: http://stone.thecoreworlds.net/
Microsoft announces IE is dead (so upgrade):
http://minutillo.com/steve/weblog/20...ces-ie-is-dead
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.