473,769 Members | 5,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how do you prevent the onclick action from being fired in IE

14 New Member
How do I in IE prevent the onclick action from being fired when I am done dragging?
have tried "window.event.c ancelBubble = true", for onmouseup , onmousedown, and onmousemove handlers. The onclick sort action always seems to get fired. Any help would be greatly appeciated.
The following demo is sortable and resizable. I basically don't want the onclick action to be fired if I am resizing a column.

Steve


[HTML]<HTML>
<HEAD>
<style>
h1, h2{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:13px;

}
.move
{
width:100%;
background-color:#99CCFF;
border-bottom:1px solid blue;
font-size:14px;
font-family:vardana;
font-color:"#33CCAA" ;
text-align:center;
}

.info
{
width:100%;
background-color:#99CCFF;
border-top:1px solid blue;
font-size:13px;
font-family:vardana;
font-color:"#33CCAA" ;
}

.panel2{
width:150; position:absolu te; border:1px solid blue; left:500; top:200; font-size:13px; font-family:vardana; }

.panel{
width:150; position:absolu te; border:1px solid blue; left:350; top:200; font-size:13px; font-family:vardana; }
.panel a:visited{color :blue;}

.panel a{text-decoration:none ;color:blue}

.panel a:hover{text-decoration:none ;}



#panel a.visited{

text-decoration:none ;

}

.menu

{

width:100%;

background-color:lightyell ow;

font-size:13px;

font-family:vardana;

}

</style>

<!--[if IE]>
<style type="text/css">
div.scrollable {
/* shrink the window, adjust for the 2 border pixels */
height:expressi on( this.getElement sByTagName('TAB LE')[0].clientHeight >= 80 ? "80px": "auto" );
overflow-x: visible;
overflow-y: auto;
}

div.scrollable table {
/* adjust for the 17 pixels for the scrollbar */
width: expression(this .parentNode.off setWidth-17);
}

/* set the table row */
div.scrollable table thead tr {
position: relative;
/* this fixes IE header jumping bug */
top: expression( this.parentNode .parentNode.par entNode.scrollT op + 'px' );
}
</style>
<![endif]-->

<!-- if mozilla -->
<style type="text/css">
html>body div.TableContai ner table tbody {
height: 20px;
overflow: auto;
}

/* add 17 for the scrollbar */
html>body div.TableContai ner div.scrollbarCo l {
width:17px;
}
</style>

<script type="text/javascript" src="http://www.kryogenix.o rg/code/browser/sorttable/sorttable.js" >
</script>

<SCRIPT LANGUAGE="JavaS cript">

N = (document.all) ? 0 : 1;
var ob;
var over = false;
var over_id ="";
var iEdgeThreshold = 10;

function TableResize_fin dPos(obj) {
var curleft = curtop = 0;
if (obj.offsetPare nt) {
curleft = obj.offsetLeft;
curtop = obj.offsetTop;
while (obj = obj.offsetParen t) {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
}
}
return [curleft,curtop];
}

/* Function that tells me if on the border or not */
function TableResize_isO nBorderLeft( objTable, objTh,event){
var left = objTh.offsetLef t;
var pos = TableResize_fin dPos(objTable);
var absLeft = pos[0] + left;

if( event.clientX < (absLeft + iEdgeThreshold) ){
return 1;
}
return 0;
}

function TableResize_isO nBorderRight( objTable, objTh,event){
var width = objTh.offsetWid th;
var left = objTh.offsetLef t;
var pos = TableResize_fin dPos(objTable);
var absRight = pos[0] + left + width;

if( event.clientX > (absRight - iEdgeThreshold) ){
return 1;
}
return 0;
}

function TableResize_get NodeName(objRef erence,nodeName )
{
var oElement = objReference;
while (oElement != null && oElement.tagNam e != null && oElement.tagNam e != "BODY") {
if (oElement.tagNa me.toUpperCase( ) == nodeName) {
return oElement;
}
oElement = oElement.parent Node;
}
return null;
}


function do_resize(objTh ,event){
if(event == null){
event = window.event;
}
var objTable = TableResize_get NodeName(objTh, "TABLE");
if( TableResize_isO nBorderLeft( objTable, objTh,event) ){
objTh.style.cur sor="e-resize";
return true;
}
else if( TableResize_isO nBorderRight( objTable, objTh,event) ){
objTh.style.cur sor="e-resize";
return true;
}

objTh.style.cur sor="";
return false;
}

function MD(e) {
MOUSTSTART_X=ev ent.clientX;
MOUSTSTART_Y=ev ent.clientY;
if (over){
if (N) {
ob = document.getEle mentById(over_i d);
X=e.layerX;
Y=e.layerY;
return false;
}

else{

ob = document.getEle mentById(over_i d);
ob2 = document.getEle mentById("MAINT ABLE");
obwidth=parseIn t(ob.style.widt h);
obwidth2=parseI nt(ob2.style.wi dth);
X=event.offsetX ;
Y=event.offsetY ;

}

}
}


function MM(e) {

if (ob) {
if (N) {
ob.style.top = e.pageY-Y;
ob.style.left = e.pageX-X;
}
else{
st=event.client X-MOUSTSTART_X+ob width;
st2=event.clien tX-MOUSTSTART_X+ob width2;

if(st>=30){
ob.style.width= st;
ob2.style.width =st2;
document.getEle mentById("statu s").innerHTML=s t;
}
document.select ion.empty();
}
}
}

function MU(e) {

if(ob != null){
document.select ion.empty();
ob = null;
}
}

if (N) {
document.captur eEvents(Event.M OUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
}

document.onmous edown = MD;
document.onmous emove = MM;
document.onmous eup = MU;
</script>


</HEAD>

<BODY>
<!--
YOU MUST HAVE TO DEFINE WIDTH ON STYLE TAB.. if you leave NULL
IT RETURNS .. ERROR..
-->
<H1>RESIZABLE TABLE COLUMN</H1>

<table style="border: 1px gray solid">
<tr>
<td>
<div class="scrollab le">

<TABLE border="1" STYLE="width:50 0px; overflow:hidden ; table-layout:fixed" ID="MAINTABLE" class="sortable ">

<THEAD>

<TR>

<TH id="panel0" class='move' onmousemove="ov er=do_resize(th is);over_id='pa nel0'" onmouseover="ov er=do_resize(th is);over_id='pa nel0'" onmouseout='ove r=false;' style='width:10 0px; overflow:hidden '>CO0</TH>

<TH id="panel1" class='move' onmousemove="ov er=do_resize(th is);over_id='pa nel1'" onmouseover="ov er=do_resize(th is);over_id='pa nel1'" onmouseout='ove r=false;' style='width:10 0px; overflow:hidden '>CO1</TH>

<TH id="panel2" class='move' onmousemove="ov er=do_resize(th is);over_id='pa nel2'" onmouseover="ov er=do_resize(th is);over_id='pa nel2'" onmouseout='ove r=false;' style='width:10 0px; overflow:hidden '>CO2</TH>

<TH id="panel3" class='move' onmousemove="ov er=do_resize(th is);over_id='pa nel3'" onmouseover="ov er=do_resize(th is);over_id='pa nel3'" onmouseout='ove r=false;' style='width:10 0px; overflow:hidden '>CO3</TH>

<TH id="panel4" class='move' onmousemove="ov er=do_resize(th is);over_id='pa nel4'" onmouseover="ov er=do_resize(th is);over_id='pa nel4'" onmouseout='ove r=false;' style='width:10 0px; overflow:hidden '>CO4</TH>

</TR>
</THEAD>
<TBODY>
<TR>

<TD>1_0</TD>


<TD><input type="text" value="this is a very long text string" style="width:10 0%" ></TD>


<TD>1_2</TD>


<TD>1_3</TD>


<TD>1_4</TD>


</TR>


<TR>

<TD>2_0</TD>


<TD>2_1</TD>


<TD>2_2</TD>


<TD>2_3</TD>


<TD>2_4</TD>


</TR>


<TR>

<TD>3_0</TD>


<TD>3_1</TD>


<TD>3_2</TD>


<TD>3_3</TD>


<TD>3_4</TD>


</TR>


<TR>

<TD>4_0</TD>


<TD>4_1</TD>


<TD>4_2</TD>

<TD>4_3</TD>
<TD>4_4</TD>

</TR>
</TBODY>
</table>

</div>
</td>
</tr>
</table>
<div id="status"></div>
</HTML>[/HTML]
Nov 12 '07 #1
4 2207
gits
5,390 Recognized Expert Moderator Expert
hi ...

please don't post your email address here ... i removed it from the post for your own protection ...

kind regards
Nov 12 '07 #2
Dasty
101 Recognized Expert New Member
I briefly looked at your code. You can not tell browser to not fire events if you already attached event handlers for some of your elements / document. If you don't want to process them you got 2 choices:

1) deatttach (temporary or permantly) event handlers from objects you dont want to be processed
2) make some kind of "state" variables where you'll keep some kind of status and adjust code in handlers to act based on conditions stored in those variables. For example in your solution you'll create global variable "var i_just_moved_co l = false" and adjust onclick handler to reflect it.

Stopping bubbling / prospecting will just tell the browser to not continue firing same event on higher / lower elements in structure.

Sorry I dont have time to give you exact solution, because it requires to dig http://www.kryogenix.o rg javascript file too (because exactly code in that include file is adding onclick handler on header cells)

Hope that helps
Nov 12 '07 #3
since
14 New Member
Dasty,
Thx for your replay. That was extremely helpful. I did notice that an alert statement caused the onclick event handler to be fired. Is it possible to fool change the location of the mouse pointer to a different location, e.g. onmouseup move to a location.

Steve
Nov 12 '07 #4
since
14 New Member
Dasty,
Typo
Thx for your replay. That was extremely helpful. I did notice that an alert statement caused the onclick event handler to be fired. Is it possible to fool change the location of the mouse pointer to a different location, e.g. onmouseup move to a location.

Steve
Thx for your replay. That was extremely helpful. I did notice that an alert statement caused the onclick event handler NOT to be fired. Is it possible to fool or change the location of the mouse pointer, e.g. onmouseup move to a location outside the resizing cell.
Nov 12 '07 #5

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

Similar topics

4
44996
by: Michael Hill | last post by:
I had this html: <tr id="action" title="click to do something" onclick="alert('mike');"> <td>a</td> <td>b</td> </tr> and it works when I click on the row, but when I try to add it dynamically like:
3
2297
by: Ryan Liu | last post by:
Can someone give a sample to prevent a row from being deleted in a datatable? I tried e.Row.RejectChanges(); in dt_RowDeleting() but seems does not work. I need verify if there other data using data in this row before actually remove it from datagrid. I can certainly control with Delete button. But if I want to allow the user to use Del key on the keyboard, I lost this kind control.
4
13564
by: sameergn | last post by:
Hi, I have an image in my HTML form which has onclick() handler. There is also a submit button and a text box. Whenever text box has focus and user presses enter, the onclick() event of image is fired with event.keyCode as undefined. I was expecting that the form would get submitted. I tried returning from onclick() handler if keyCode is null, but the
17
5484
by: emma.sax | last post by:
Hi all, I have a form where we would like the user to input their email address twice, to ensure they've typed it correctly, as is found on most sign-ups I'm looking for a solution to the problem where a user (and me it has to be said) just either highlights the email address with their mouse (or Ctrl-A) and then Ctrl-C, Ctrl-P (or right-click copy, right-click paste) into the next field down.
5
13963
by: Stuart Shay | last post by:
Hello All I am working on ASP.NET 1.1 Custom Pager that allows a User to Enter a Number in a TextBox and go to the page selected. Since the OnClick Event does not work in ASP.NET 1.1 for a TextBox I want to use a hidden button to fire when the Onclick Event is fired for the TextBox.
3
6509
by: Michael_R_Banks | last post by:
I'm trying to dynamically build a table that allows users to remove rows when they click a corresponding button. For some reason, whenever I add the button to the table, it never fires the onclick event. I'm stumped with this one, any assistance would be appreciated. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"...
13
323
by: Mtek | last post by:
Hi, We have a form defined with buttons like this: <a class="save_menu" href="javascript:document.Detail_Screen.action = 'savedata.php?screen=EDIT';document.Detail_Screen.submit();">Update</ a> The form also has an onSubmit action to vall a validation routine:
6
4157
by: Gustaf | last post by:
I'm working on a code generator for documentation of VBA projects. It outputs HTML docs, including simple JS. I don't have much experience with JS however, so I need some help with this sample output: http://www.algonet.se/~gustafl/test/frmCalcMany.html Whenever I click 'Show source' after scrolling down a bit, the page instantly jumps to the top of the page, which may hide the source. I understand this is because of href="#", but I don't...
2
2780
by: Num GG | last post by:
Hi all, Given this simple code: <div id="mydiv" ondblclick="alert(id)" //parent div Div4 bla bla bla bla on div 4 <div id="myembeddeddiv"ondblclick="alert(id)" // child div Div4.1 bla bla bla on embedded Div </div> </div>
0
9589
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
10219
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
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
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
7413
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
5310
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...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
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

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.