Reputation: 69
I need firefox browser open a new tab. But this code below open new window.
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);
Upvotes: 2
Views: 281
Reputation: 37238
Do this:
var tab = gBrowser.loadOneTab('http://giaiphapthuonghieu.vn', {referrerURI: Services.io.newURI('http://giaiphapthuonghieu.vn', null, null)});
So your code would look like this:
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);
Upvotes: 1
Reputation: 23816
You can give only one url at once in window.open
and use _blank
to open in new tab instead of window
tabs[0]=window.open("http://giaiphapthuonghieu.vn" '_blank');
tabs[0].focus();//to focus tab
Upvotes: 0