When would you set location
to a URL string versus setting location.href
?
location = \"http://www.stackoverflow.com\";
Like as has been said already, . location
is an objectBut that person suggested using either. But, you will do better to use the .href
version.
Objects have default properties which, if nothing else is specified, they are assumed. In the case of the location
object, it has a property called .href
. And by not specifying ANY property during the assignment, it will assume "href" by default.
This is all well and fine until a later object model version changes and there either is no longer a default property, or the default property is changed. Then your program breaks unexpectedly.
If you mean href
, you should specify href
.