我需要firefox浏览器打开一个新选项卡。但下面的代码打开新窗口。
window.addEventListener('click', function(event) {
var doc = event.originalTarget;
var origEl = event.target || event.srcElement;
if(origEl.tagName === 'A' || origEl.tagName === 'a') {
tabs[0]=window.open("http://giaiphapthuonghieu.vn","http://giaiphapthuonghieu.vn");
}
}, false);
这样做:var tab = gBrowser.loadOneTab('http://giaiphapthuonghieu.vn', {referrerURI: Services.io.newURI('http://giaiphapthuonghieu.vn', null, null)});
window.addEventListener('click', function(event) {
var doc = event.originalTarget;
var origEl = event.target || event.srcElement;
if(origEl.tagName === 'A' || origEl.tagName === 'a') {
tabs[0] = gBrowser.loadOneTab('http://giaiphapthuonghieu.vn', {referrerURI: Services.io.newURI('http://giaiphapthuonghieu.vn', null, null)});
}
}, false);
您可以在window.open
中一次只给出一个url,并使用_blank
在新选项卡中打开而不是窗口
tabs[0]=window.open("http://giaiphapthuonghieu.vn" '_blank');
tabs[0].focus();//to focus tab