Results 1 to 2 of 2

Thread: window.location vs window.location.href

  1. #1
    Join Date
    Sep 2006

    window.location vs window.location.href

    What are the difference between the window.location and window.location.href?

    When to use the one not the other?



  2. #2
    Join Date
    Feb 2006
    window.location is an object, it has several properties-
    host,protocol,pathname,hash,search and href
    and reload and replace methods.

    window.location.href is the string value of the URL.

    Use location when you want the object, href when you want the string.

    the toString() method of the location object returns the location.href value,
    so using location where it expects a string will convert it to a string.
    Last edited by mrhoo; 05-22-2007 at 05:42 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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