View Full Version : location object question
08-01-2011, 12:10 AM
if location is a property of window object that returns a string and im appending .indexOf() to location why is it not working?
08-01-2011, 12:32 AM
location (window.location) refers to an object- it has a toString method that returns the location's url.
This happens for example, when you alert(location) or document.write(location).
But location is an object with several properties and methods.
To use string methods on the location.href, explicitly get a string from the location object.
You can use var url= location.href or url=String(location).
08-01-2011, 03:10 AM
oh ok that makes total sense. So I wasn't able to get any kind of string because the location object is just the address bar itself meaning that it can not return a string. But once i have access to the location object i can then use it's own properties like 'href' and that will give me the url as the returned string. Is that about right?
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.