window.location.Replace in Firefox插件中删除了整个Chrome!
-
23-09-2019 - |
题
我正在使用 nsIWebProgressListener
界面 找出是否已更改URL。如果有的话,我想重写链接。这是一个摘要(从上面的链接中摘自页面底部的代码)
var myExt_urlBarListener = {
QueryInterface: function(aIID)
{
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
aIID.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
},
onLocationChange: function(aProgress, aRequest, aURI)
{
myExtension.processNewURL(aURI);
},
onStateChange: function(a, b, c, d) {},
onProgressChange: function(a, b, c, d, e, f) {},
onStatusChange: function(a, b, c, d) {},
onSecurityChange: function(a, b, c) {}
};
var myExtension = {
oldURL: null,
init: function() {
// Listen for webpage loads
gBrowser.addProgressListener(myExt_urlBarListener,
Components.interfaces.nsIWebProgress.NOTIFY_LOCATION);
},
uninit: function() {
gBrowser.removeProgressListener(myExt_urlBarListener);
},
processNewURL: function(aURI) {
if (aURI.spec == this.oldURL)
return;
// now we know the url is new...
start_work(aURI.spec);
this.oldURL = aURI.spec;
}
};
window.addEventListener("load", function() {myExtension.init()}, false);
window.addEventListener("unload", function() {myExtension.uninit()}, false);
以及处理更改的功能:
function start_work(url)
{
result = check(url);
if (result) {
setCookie('bws', 'true', 1, '/');
window.location = result; // or window.location.replace, doesn't matter
}
}
这就是发生的!alt文本http://grab.by/20ep如您所见,整个浏览器/地址栏/镀铬都消失了!
有什么帮助吗?
没有正确的解决方案
其他提示
简单:添加 window.content.location
不隶属于 StackOverflow