I wrote a Firefox extension that requires the URL of the source document. Normally, JavaScript document.URLcould achieve this, but it is different.
See my example below:

As you can see, 4 tabs are open:
- BBC Homepage
- Add-in manager
- Amazon.com
- Stack overflow
And the StackOverflow.com page is currently being viewed (.. really).
My question is: how can I get the url of the active user window? (i.e. http://www.stackoverflow.com ).
Below is the code panel.html.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href=panel.css rel="stylesheet" type="text/css">
</head>
<body>
<header><h3>Where aM I</h3></header>
This Mozilla extension will display the current <i>background</i> URL
<main>
<fieldset>
<legend>Click the Button</legend>
<button onclick="PageViewing()">Fetch</button>
</fieldset>
</main>
<script>
function PageViewing() {
alert(document.URL);
}
</script>
</body></html>
EDIT
If it is placed in a file main.js, this piece of code works:
var tabs = require("sdk/tabs");
console.log("URL of active tab is " + tabs.activeTab.url);
, , P-Name/ lib, P-Name/ datastrong > - ?
