473,804 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stopping ctl-click in IE

I have a situation where I want to react to a ctrl-click on a <span> and
it works in Netscape and Firefox browsers but in IE I have a problem.
In IE I do catch the ctrl-click but IE also renders the span in inverse
video, essentially selecting the item.

Here is a short sample that demonstrates the issue:

<html><head>
<script type="text/javascript">

function Clicked(evt){
evt.cancelBubbl e=true;
}

</script></head>
<body>
<SPAN onClick="Clicke d(event);">clic k me</SPAN>
</body></html>

I thought the cancelBubble would prevent the event from triggering the
selection from happening but I think that the ctrl-click selection
happens before I get control.

Is there a way to prevent the selection from being rendered on ctrl-
click while still allowing my javascript to react to the event?

browser versions used
ie 6.0.2800
firefox 0.9
netscape 7.1
Jul 23 '05 #1
6 5918
Dave wrote:
I have a situation where I want to react to a ctrl-click on a <span> and it works in Netscape and Firefox browsers but in IE I have a problem. In IE I do catch the ctrl-click but IE also renders the span in inverse video, essentially selecting the item.

Here is a short sample that demonstrates the issue:

<html><head>
<script type="text/javascript">

function Clicked(evt){
evt.cancelBubbl e=true;
}

</script></head>
<body>
<SPAN onClick="Clicke d(event);">clic k me</SPAN>
</body></html>

I thought the cancelBubble would prevent the event from triggering the selection from happening but I think that the ctrl-click selection
happens before I get control.

Is there a way to prevent the selection from being rendered on ctrl-
click while still allowing my javascript to react to the event?

browser versions used
ie 6.0.2800
firefox 0.9
netscape 7.1


Strictly MSIE:

<span onselectstart=" return false;">...eeee eeesh!!</span>

Jul 23 '05 #2
Dave <noemail@anyadd ressiown_invali d.com> writes:
<script type="text/javascript">

function Clicked(evt){
evt.cancelBubbl e=true;
}

</script></head>
<body>
<SPAN onClick="Clicke d(event);">clic k me</SPAN>
</body></html>

I thought the cancelBubble would prevent the event from triggering the
selection from happening but I think that the ctrl-click selection
happens before I get control.


Assigning true to "event.cancelBu bble" is the IE way of stopping further
event handlers in the page, not stopping the default behavior of the
click. To do that, assign false to "event.returnVa lue".

A general function that works for standards compliant browsers as well:
---
function clicked(evt){
if (evt.preventDef ault) {
evt.preventDefa ult(); // The W3C DOM way
} else {
evt.returnValue = false; // The IE way
}
}
---

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #3
In article <oe**********@h otpop.com>, lr*@hotpop.com says...

A general function that works for standards compliant browsers as well:
---
function clicked(evt){
if (evt.preventDef ault) {
evt.preventDefa ult(); // The W3C DOM way
} else {
evt.returnValue = false; // The IE way
}
}
---


Thanks for the response. It didn't work for me. I included the updated
example below.

I noticed one thing though. If I put an alert immediately before the
evt.returnValue = false; I see that by the time the alert box is
visible, "click me" is already highlighted. So I'm not sure how that
event property could have an effect on the outcome.
<html><head>
<script type="text/javascript">

function Clicked(evt){
if (evt.preventDef ault) {
evt.preventDefa ult(); // The W3C DOM way
} else {
evt.returnValue = false; // The IE way
}
evt.cancelBubbl e=true;
}

</script></head>
<body>
<SPAN onClick="Clicke d(event);">clic k me</SPAN>
</body></html>
Jul 23 '05 #4
In article <11************ *********@g14g2 000cwa.googlegr oups.com>,
fe******@hotmai l.com says...
Strictly MSIE:

<span onselectstart=" return false;">...eeee eeesh!!</span>


That's too bad it's a MSIE specific solution, but it did work.

Thanks!
Jul 23 '05 #5
DU
Lasse Reichstein Nielsen wrote:
---
function clicked(evt){
if (evt.preventDef ault) {
evt.preventDefa ult(); // The W3C DOM way
} else {
Shouldn't that be else if(window.event )
{event.returnVa lue = false;};
evt.returnValue = false; // The IE way
}
}


DU
--
The site said to use Internet Explorer 5 or better... so I switched to
Mozilla 1.7.6 :)
Jul 23 '05 #6
DU <dr*******@hotN OSPAMmail.com> writes:
Lasse Reichstein Nielsen wrote:
---
function clicked(evt){ if (evt.preventDef ault) {
evt.preventDefa ult(); // The W3C DOM way
} else {


Shouldn't that be else if(window.event )
{event.returnVa lue = false;};


In this scenario, the function was called from an HTML event
handler:
<blah onblah="clicked (event); .. ">
so "evt" does refer to the global event handler in IE too.

It should probably be:

<blah onblah="return clicked(event); ">
....
function clicked(evt) {
...
if (evt.preventDef ault) {
evt.preventDefa ult();
} else {
evt.returnValue = false; // can't hurt
return false;
}
}

.... to handler thr likes of Netscape 4.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2833
by: Ike | last post by:
I have a combobox on an activex ctl file, (TobulControl.ctl). I have a button on the ctl file too, and when the button is pressed, a dialog box opens. Within the code of this dialog box, I refer to this combobox with: If TobulControl.Combo1.ListIndex <> 8 Then whereupon at this line I get a "Runtime Error 424 : Object Required" How can I access the ctl file. It;s name is TobulControl.ctl, and it is saved as TobulControl.ctl ? Thanks,...
1
10354
by: gilgantic | last post by:
Is there anyway of eliminating duplicate entries as the database loads data using SQLLDR and/or .ctl (Control File)? I use the following command line using SQLLDR and a control file to load my data, but the sample.dat file has duplicate information. I would like to be able to eliminate this, since I have know ability to manipulate the sample.dat. ${ORACLE_HOME}/bin/sqlldr $USERPW /home/sample/sample.ctl ############# sample.ctl...
5
2621
by: CG | last post by:
Hi I have developed a Windows Service When I try to start the Service it tells me that it cannot start as there may not be any work to do When I comment out below line of code in my OnStart event.... objEventLog.EnableRaisingEvents = Tru ....It starts fin I have the same issue when stopping the service because of below line of code in my OnStop even
8
2259
by: dixie | last post by:
I want to run an event when I press the Ctl key simultaneously with the K key. How do I achieve this in VBA? dixie
0
1361
by: Dev | last post by:
Dear Friends, How to disable the start,windows task manager,Ctl+Alt+Del buttons through C#?, If any one knows please let me know...Any suggestions would be greatly appreciated. Thanks, Dev
0
848
by: G.Ashok | last post by:
Hi, I just installed VS.Net 2003 and upgraded my project to 2003. Immediately found the following new behavior which causes my solution working erratic. In the leave event of a control (e.g. TextBox) I select (set focus to) another control cause the leave event to raises again of the source text box. Steps to reproduce.
2
1194
by: Paul | last post by:
I have a MDI form which hosts numerous MdiChildren forms. I want to prevent the users from toggling to other MdiChildren forms. The program allows it by pressing Ctl+F6 or Ctl+Tab. In the MDI form I use the KeyUp event and set Handles = True: Private Sub FrontierMDI_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp Select Case e.KeyCode Case Keys.F6
0
977
by: Tony Nelson | last post by:
I've been trying to figure out why Ctl-C sometimes doesn't interrupt yum. It appears to be unresolved Python bug 926423, unresolved proposed patch 1102879, don't know if anything ever came of it. Note that I cannot ask all yum users to apply the patch. I'm not sure I should be getting rid of the timeout, either. When a Ctl-C is lost, sometimes it is silently eaten, and other times it becomes socket.error(11,...) (EWOULDBLOCK). As...
0
1094
by: Gary Brown | last post by:
Hi, I have implemented Cut item in a ListView with Ctl-X as the shortcut key. Unfortunately this supercedes Ctl-X when used to edit a label. What is the easiest way around this? The Ctl-X is assigned as a property value to the menu of a form that uses a custom control that is subclassed to ListView. Thanks, Gary
0
1465
by: eldamiani | last post by:
Ineed a help. I want to ask, how I can do dialog box window which is a normal form, but causes stopping the code execution in form which call out this dialog box. I have MessageBox.Show("Operations"); FormDialog frm = new FormDialog(); frm.Show() //not ShowDialog() //now the code should be stopping, but i don't know how. MessageBox.Show("Operations"); I need something such as "ReadLine()" in console application, which is...
0
9715
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10603
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3003
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.