By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,572 Members | 963 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,572 IT Pros & Developers. It's quick & easy.

how to send "click middle mouse button" to link

P: n/a
Hello,

I need to able to write JS that will click on a link with the middle
mouse button - so that the link target will open in a new window or
tab - using firefox. Or is there a better (more reliable) way to have
the link open in a new window/tab (using JS)? I have no control over
the JS already on the page - this is for a selenium user extension
that I'd like to write.
Thanks,
Warren

Sep 7 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Sep 8, 5:53 am, wpollans <wpoll...@gmail.comwrote:
Hello,

I need to able to write JS that will click on a link with the middle
mouse button - so that the link target will open in a new window or
tab - using firefox. Or is there a better (more reliable) way to have
the link open in a new window/tab (using JS)? I have no control over
the JS already on the page - this is for a selenium user extension
that I'd like to write.
You can try using dispatchEvent:

<URL:
http://groups.google.com.au/group/co...cea9cdf065a524
>
But it probably won't do what you expect, clicking the scroll wheel is
not the equivalent of a middle mouse button click[1]. In Firefox, a
scroll wheel click on a link opens the link in a new tab if
preferences are set to do that, the link itself never receives the
click.

In Safari, a click is sent to the link but you can only send a middle
button click, which is different to a scroll wheel click, and the link
is opened in a new window.
1. You may be able to change preferences for your mouse keys to make a
scroll wheel click the same as a middle mouse button click, but that
can't be relied upon.
--
Rob

Sep 8 '07 #2

P: n/a
wpollans wrote:
Hello,

I need to able to write JS that will click on a link with the middle
mouse button - so that the link target will open in a new window or
tab - using firefox. Or is there a better (more reliable) way to have
the link open in a new window/tab (using JS)? I have no control over
the JS already on the page - this is for a selenium user extension
that I'd like to write.
Thanks,
Warren
A few ways:
1. you can open a window via window.open method; the open method is as
follows: open (URL, windowName[, windowFeatures]).
2. you may designate a div to which you render the response from setting
the src of a hidden iframe; the rendering is done by replacing the
innerHTML of the div.
3. you may use AJAX method to get the contents of you wish to render,
and when you get the response render into div via innerHTML replacement.

Note that in the case of the divs you may even make these divs popup by
setting their position.

Sep 8 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.