redirects w/ js

Discussion in 'Javascript' started by Magic-chef, Jun 29, 2003.

  1. Magic-chef

    Magic-chef Guest

    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?
     
    Magic-chef, Jun 29, 2003
    #1
    1. Advertising

  2. 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/2003/5/30/microsoft-announces-ie-is-dead
     
    David Dorward, Jun 29, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark
    Replies:
    0
    Views:
    315
  2. Gery D. Dorazio
    Replies:
    0
    Views:
    471
    Gery D. Dorazio
    Jan 29, 2004
  3. darrel

    Postback confusion re: redirects

    darrel, May 4, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    791
    darrel
    May 4, 2004
  4. www.MSmobiles.com
    Replies:
    1
    Views:
    407
    Teemu Keiski
    Jul 18, 2004
  5. Replies:
    1
    Views:
    335
    Nicole Calinoiu
    Feb 2, 2005
Loading...

Share This Page