Link to home
Start Free TrialLog in
Avatar of sphere301
sphere301

asked on

Can I read IE address bar?

Hi,

is it possible with javascript/vbscript to get what's in IE address bar(the URL field)?
I don't mean document.location.href, but the text from the address bar.

Thanks
Avatar of a.marsh
a.marsh

Eh?

I'm afraid you've lost me....

And it is window.location not document.location.

:o)

Ant
Do you mean the bar at the bottom of the explorer window that displays links when you hover over them?
need some more info..
Avatar of sphere301

ASKER

No, I mean the address bar which usually stays at the top of the browser window and where you enter the url you want to visit. For example, my address bar now shows
https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=javascript&qid=20162676

ASKER CERTIFIED SOLUTION
Avatar of bebonham
bebonham

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the location object is bound to both the document and window in IE (this provides sourced elements with their own location object)...but this reference should not be used if cross-compatibility is an issue; it will work with netscape up to at least 4.0 (even though they suggest using document.URL)

...because netscape 6 has yet to implement LiveConnect i don't program for the environment and couldn't even begin to tell you what would be the appropriate usage.  it's always a safe bet to use window.location if you're not needing to change or fetch location objects from sourced elements.
document.URL will get you the URL string for the current page. Carries any querystring too.

You can't WRITE to that, it's a read-only object.
I don't want to write to the URL field, I just want to check what's in there. This may not be the same as the url of the currently loaded document because after the page loads you can type there whatever you like and the same page will be still loaded
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
points to bebonham
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

ahosang
EE Cleanup Volunteer
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange