Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get URL of current document in any case?

0 views
Skip to first unread message

Lev Serebryakov

unread,
Apr 19, 2005, 5:22:14 AM4/19/05
to

To enable/disable my command I need to be sure, that current document has
`http://...' URL.
Now I'm detecting this like this:

=====
var url = document.commandDispatcher.focusedWindow.location;
return ( url.protocol == "http:" || url.protocol == "https:" );
=====

But it doesn't work, if focused window is URL bar, Search bar or something
like this. It is not what I want: in such case command is enabled too, of
course. How could IO get URL of docuement in active (or only one) tab in
FF and Mozilla?

Lev Serebryakov
Programmer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


Neil

unread,
Apr 19, 2005, 10:48:39 AM4/19/05
to
Lev Serebryakov wrote:

> To enable/disable my command I need to be sure, that current
> document has `http://...' URL.
> Now I'm detecting this like this:
>
> =====
> var url = document.commandDispatcher.focusedWindow.location;
> return ( url.protocol == "http:" || url.protocol == "https:" );
> =====
>
> But it doesn't work, if focused window is URL bar, Search bar or
> something like this. It is not what I want: in such case command is
> enabled too, of course. How could IO get URL of docuement in active
> (or only one) tab in FF and Mozilla?

Well, the correct way is getBrowser().currentURI.schemeIs("http") ||
getBrowser().currentURI.schemeIs("https"); but the error with your code
is that you wanted content.location.protocol

--
Warning: May contain traces of nuts.

0 new messages