bard / mozrepl

Remotely control Firefox and other Mozilla apps with JavaScript
https://github.com/bard/mozrepl/wiki/
510 stars 64 forks source link

window.document.URL returning browser URL #64

Closed erjoalgo closed 9 years ago

erjoalgo commented 9 years ago
repl> window.document.title
"Tutorial · bard/mozrepl Wiki - Iceweasel"
repl> window.document.URL
"chrome://browser/content/browser.xul"
repl> 

Shouldn't this be https://github.com/bard/mozrepl/wiki/Tutorial ?

pyhedgehog commented 9 years ago

This is intended - window object corresponds to window itself - chrome window. Use content for content window of currently selected tab.

erjoalgo commented 9 years ago

Where is this context documentation? Can you please tell me how to get the URL of the current window?

pyhedgehog commented 9 years ago

Sorry, I've made a tipo - content, instead of context. Documented (as always) on MDN: content. So to get url of browser content of selected tab of topmost browser window, you should write:

repl> content.document.location.href
"https://github.com/bard/mozrepl/issues/64#issuecomment-137261813"
erjoalgo commented 9 years ago

thanks, this worked well