Get the current document address (Firefox extension)

Does anyone know how to get the URI of the current page / tab?

+2


source to share


3 answers


window.location.href

contains the URI of the Windows document.



+1


source


This page seems to have what you are looking for



and this one may have more information you will find useful

+4


source


The accepted answer here is wrong, but the related comment is much closer.

The phsr FAQ linked to "Get the current tab document", but Mozilla changed all of its links without maintaining backward compatibility and thus breaking a lot of linked sites.

Correct url: https://developer.mozilla.org/en/Extension_Code_Snippets/Tabbed_Browser#Getting_document_of_currently_selected_tab

This document explains how to get the document object the way you would expect to get in the Javascript web interface.

Given that you can easily request gBrowser.contentDocument.location.href

or content.document.location.href

. If your use case is more complex than a script running in an active tab (for example, your script is running in a XUL popup), then your best bet is to read the FAQ.

+3


source







All Articles