Firefox 脚本语言:活动选项卡的 URL 和打开选项卡的计数
编辑:我能够更进一步:)
伪代码(我想要的)
if (CurrentTabURL == empty Tab) and (Tab.Count == 1)
{close Firefox}
else
{close Tab}
我的代码(只有 if 语句不起作用。两个操作都有效)
if (gBrowser.currentURI == "")
and (tabbrowser.browsers.length == 1)
then
goQuitApplication();
else
gBrowser.removeTab(gBrowser.mCurrentTab);
end
此链接对我帮助很大。
Edit: I was able to go one step further :)
PSEUDO CODE (what I want)
if (CurrentTabURL == empty Tab) and (Tab.Count == 1)
{close Firefox}
else
{close Tab}
MY CODE (only the if statements don't work. Both actions are working)
if (gBrowser.currentURI == "")
and (tabbrowser.browsers.length == 1)
then
goQuitApplication();
else
gBrowser.removeTab(gBrowser.mCurrentTab);
end
This link helped me a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
gBrowser.currentURI
是一个nsIURI
实例。如果您想将 URL 与字符串进行比较,您应该查看gBrowser.currentURI.spec
。顺便说一句,“空选项卡”的 URL 是about:blank
。另外,我猜你想使用 JavaScript?更正的代码:gBrowser.currentURI
is annsIURI
instance. If you want to compare the URL to a string you should look atgBrowser.currentURI.spec
. The URL of an "empty tab" isabout:blank
by the way. Also, I guess that you want to use JavaScript? Corrected code: