The My Opera forums have been replaced with forums.opera.com. Please head over there to discuss Opera's products and features

See the new Forums

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

30. November 2011, 13:21:32

Mintsoft

Posts: 54

Open new tab from popup

Hi Guys,

I was trying to make a new tab open in a link from my extension. Using
window.open("preferences.html");
didn't cut the mustard, however after some dragonflying I came up with this:
opera.extension.bgProcess.opera.extension.tabs.create(
	{
		url: "preferences.html", 
		focused: true
	}); 


Is this seriously the only way to do it; access the bgProcess then back to the opera.extension object?! Or have I missed a much easier method somewhere?

Thanks
-Rob
Presto/2.10.289 Opera 12.00 on Windows 7 Professional 64Bit

30. November 2011, 16:31:17

d4n3

Posts: 957

You're not really going "back to" the same opera.extension object - they are two different objects in two different contexts and only the background script's opera.extension has the "tabs" property available.

And yes, this is the most straightforward way to achieve this.

You are also missing one thing - window.open actually works in the extension popup (just tested it), but it's subject to normal popup blocking behaviour - so by default it will be blocked if it's not preceded by a user click. Try it with F12 -> Open all pop-ups.

I think you're much better off using the method you posted. Just wrap it in a function and get on with your life smile

2. December 2011, 10:03:18

Mintsoft

Posts: 54

Originally posted by d4n3:

I think you're much better off using the method you posted. Just wrap it in a function and get on with your life smile


That's what I suspected! Thanks for the confirmation.
Presto/2.10.289 Opera 12.00 on Windows 7 Professional 64Bit

Forums » Dev.Opera » Opera Extensions Development Discussions