SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Difference between window. & document.

    I was doing a javascript redirect on one of my pages and was wondering what the difference is between window.location.href and document.location.href?

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    northern Maine
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Apparently there is no difference:
    (document.location === window.location) == true
    but it is better coding practice to use window.location.href over document.location.href, don't ask me why but that's the way it is.
    Jason - Contact Me
    Supermoderator @ CodingForums

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Ann Arbor, MI
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In a page using frames, does not document.location refer to each individual frame, and window.location refer to the entire window? You can, for instance, change the content of one frame with:

    document.location.href = "foo.htm"

    whereas on the same page

    window.location.href = "foo.htm"

    would change the content of the entire window.

    But I may be wrong.

    LL

  4. #4
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're wrong =), window.location.href will also change the current frame.
    ck :: bringing chris to the masses.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Ann Arbor, MI
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Huh. I keep forgetting not to try to apply actual logic to programming/scripting


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
  •