从Firefox扩展中打开当前选项卡/窗口中的URL [英] Opening a URL in current tab/window from a Firefox Extension

查看:133
本文介绍了从Firefox扩展中打开当前选项卡/窗口中的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



例如,如果你想在菜单项中打开一个URL,在我的overlay.xul文件中,我有以下行:

 < menuitem label =访问主页oncommand =窗口。位置=的 'http://www.somepage.com'/> 

但是在firefox中,当我点击菜单项时,它会打开URL,浏览器的整个布局。



有什么正确的方法可以做到这一点?

解决方案
 < menuitem label = 访问首页oncommand =content.wrappedJSObject.location ='http://www.somepage.com'/> 


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?

解决方案

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'"/>

这篇关于从Firefox扩展中打开当前选项卡/窗口中的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆