Opening a URL in current tab/window from a Firefox Extension

aryo picture aryo · Nov 23, 2008 · Viewed 11.2k times · Source

I am creating a Firefox Extension...what would be the javascript to open a URL in the current tab from a menuitem?

e.g. in my overlay.xul file i have the following line:

<menuitem label="Visit homepage" oncommand="window.location='http://www.somepage.com'"/>

but in firefox, when i click on the menu item, it opens the URL but it screws up the entire layout of the browser.

What's the correct way to do this?

Answer

aryo picture aryo · Nov 23, 2008

After browsing around, I found that I had to replace the above code with this:

<menuitem label="Visit homepage" oncommand="content.wrappedJSObject.location='http://www.somepage.com'"/>