SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    eez
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Should I use location.href or window.location.href or window.location ?

    Hi!

    In order to do a redirect in javascript, should I write location.href = url or window.location.href = url or window.location = url ?

    Question 2: Redirecting such as this aborts the execution of the page, right?

    Thanks

  2. #2
    SitePoint Addict jtrelfa's Avatar
    Join Date
    Oct 2004
    Location
    Troy, Mi
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you have access to the server-side code, such as PHP, you can use the 'header' function to redirect.

    In PHP, document.location.href is what I've typically used and haven't had any problems with browser compatibility.

    If you change the document location, it will abort script processing since you're moving to a new page.

  3. #3
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    eez
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •