470,612 Members | 2,521 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,612 developers. It's quick & easy.

Workaroud for Ctrl-Click in Firefox

I saw a post about this issue, but it seemed to be closed.

I needed a code that allowed to handle click + ctrl in a form object such as a textfield. In order to work also on IE, I wrote the textfield onclick property like this

onclick="function(event){ if( event.ctrlKey) this.select()}"

and ... for Firefox, I wrote this piece of code inside a script element:

function clickPlus(){
try
{
window.addEventListener('click' ,
function(e)
{
if(e.target.tagName == 'INPUT')
{
if(e.ctrlKey)
{
try
{
e.target.select();
}
catch(ie){}
}
}
} , true);
}
catch (ie) {}
}

The try-catch around is a way to prevent IE complaining. Now it works in both browsers. The function was called in the body onload event.
Oct 22 '07 #1
1 1839
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

Thanks for sharing this code.

I saw a post about this issue, but it seemed to be closed.
This was probably because it was in the newsgroup archives.

The try-catch around is a way to prevent IE complaining.
You could check for support of window.addEventListener instead.

Have you tested in other browsers?
Oct 22 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Mike Maxwell | last post: by
4 posts views Thread by Scott | last post: by
10 posts views Thread by chirs | last post: by
13 posts views Thread by Kai Grossjohann | last post: by
3 posts views Thread by Greg | last post: by
3 posts views Thread by Glen Hong | last post: by
2 posts views Thread by s99999999s2003 | last post: by
11 posts views Thread by Bookham Measures | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.