redirects w/ js

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Magic-chef

    redirects w/ js

    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?

  • David Dorward

    #2
    Re: redirects w/ js

    Magic-chef wrote:
    [color=blue]
    > 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?[/color]

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

    Comment

    Working...