Actually, this is interesting. I'm having trouble opening a link in a
tab when initiating the event in JavaScript, even when the link is not
in the background.

1. If I try to click a link on a page (even if not in the background)
through JavaScript, it opens in the new window. Using code like this:

var eventObj = document.createEvent('MouseEvents');
eventObj.initEvent( "click", true, false );
document.getElementById("my_link").dispatchEvent(eventObj);

2. If I click the same link with the real mouse, it opens in a tab.

3. If I try to use jquery $("#my_link").click() nothing happens.

Does anyone know how I can mimic the real behavior of clicking a link
so that it opens a tab?

--Jon


On Dec 11, 12:47 pm, Jon Stritar <jstri...@gmail.com> wrote:
> That's what I figured. We're trying to move away from that API since
> the warning message when installing freaks people out. Thanks for your
> help.
>
> --Jon
>
> On Dec 11, 12:30 pm, Mohamed Mansour <m...@chromium.org> wrote:
>
> > You can't in the background page because it exists once in the background
> > per extension per browser. And you can have at most one browser open at any
> > time. While a browser can open many windows which consists of many tabs.
>
> > If you really want to open a new tab, you need permission from the tabs 
> > apihttp://code.google.com/chrome/extensions/tabs.html#method-create
>
> > <http://code.google.com/chrome/extensions/tabs.html#method-create>As far as
> > I know, thats the only way, anyone else can correct me if I am mistaken :x
>
> > -Mohamed Mansour
>
> > On Fri, Dec 11, 2009 at 12:01 PM, Jon Stritar <jstri...@gmail.com> wrote:
> > > Thanks, works well for the links in my popup. When I try to use the
> > > same technique from my background page it opens the link in a new
> > > window with no tabs or toolbars. Any ideas on how to get that to be a
> > > new tab on an existing window?
>
> > > --Jon
>
> > > On Dec 11, 11:41 am, Mohamed Mansour <m...@chromium.org> wrote:
> > > > Hi Jon,
>
> > > > You can use the target = blank if you want that approach.
>
> > > > <a href="http://chromium.org"; target="_blank"> open new tab </a>
>
> > > > -Mohamed Mansour
>
> > > > On Fri, Dec 11, 2009 at 11:31 AM, Jon Stritar <jstri...@gmail.com>
> > > wrote:
> > > > > Is there a way to open a link in a new tab without going through the
> > > > > tabs API (chrome.tabs.create)? We really don't need access to the tabs
> > > > > and browser history for this, but I think window.open only creates new
> > > > > windows. Any ideas?
>
> > > > > --Jon
>
> > > > > --
>
> > > > > You received this message because you are subscribed to the Google
> > > Groups
> > > > > "Chromium-extensions" group.
> > > > > To post to this group, send email to
> > > chromium-extensi...@googlegroups.com.
> > > > > To unsubscribe from this group, send email to
> > > > > chromium-extensions+unsubscr...@googlegroups.com<chromium-extensions%2bunsubscr...@googlegroups.com>
> > > <chromium-extensions%2bunsubscr...@googlegroups.com<chromium-extensions%252bunsubscr...@googlegroups.com>
>
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/chromium-extensions?hl=en.
>
> > > --
>
> > > You received this message because you are subscribed to the Google Groups
> > > "Chromium-extensions" group.
> > > To post to this group, send email to chromium-extensi...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > chromium-extensions+unsubscr...@googlegroups.com<chromium-extensions%2bunsubscr...@googlegroups.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/chromium-extensions?hl=en.
>
>

--

You received this message because you are subscribed to the Google Groups 
"Chromium-extensions" group.
To post to this group, send email to chromium-extensi...@googlegroups.com.
To unsubscribe from this group, send email to 
chromium-extensions+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/chromium-extensions?hl=en.


Reply via email to