|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
Does someone know how to prevent the event bubbling in firefox I am using Firefox version 1.5.0.7 and i have tryed a hell lot of commands to stop the event bubbling ... but nothing worked out... I am pasting the code below pls go through it ... i need some help very badly coz i need to be able to stop the Table Row and Table onClick events from firing when the image inside it is clicked... Pls hlp Regards Anand CODE:: Code:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript">
function img()
{
alert('image');
//event.preventBubble();
//event.stopPropagation();
//event.cancelBubble = true;
//return false;
alert(event.bubbles);
}
function tr()
{
alert('Table Row');
return false;
}
function t()
{
alert('Table');
return false;
}
function load()
{
//event.preventDefault();
//event.stopPropagation();
//event.cancelBubble = true;
//event.returnValue = false;
}
</script>
</head>
<body onload="load();">
<table id="t" width="50%" border="1" onclick="t();">
<tr id="tr" onclick="tr();">
<td><a href="#" onclick="img();" id="img"><img src="file:///D|/Site Files/images/css_design_01/gblnav_left.gif" alt="XUL" width="5" height="32" border="0" /></a></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
|
|
#2
|
||||
|
||||
|
__________________
Support requests via PM will be ignored! |
|
#3
|
|||
|
|||
|
Thanks for that post ... it was a life saver ... THANKS .....
I used the info from that link you post to get my page work ... this is the code that works ... i am pasting this so that someone else looking for a clear solution to cancel bubble event wont have to search too long ... like what i did .. This is the solution ... Code:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript">
function img(evnt)
{
alert('image');
var e = (window.event) ? window.event : evnt;
e.cancelBubble = true;
return false;
}
function tr(evnt)
{
alert('Table Row');
var e = (window.event) ? window.event : evnt;
e.cancelBubble = true;
return false;
}
function t(evnt)
{
alert('Table');
var e = (window.event) ? window.event : evnt;
e.cancelBubble = true;
return false;
}
</script>
</head>
<body>
<table id="t" width="50%" border="1" onclick="t(event);">
<tr id="tr" onclick="tr(event);">
<td><a href="#" onclick="img(event);" id="img"><img src="../../../Site Files/images/css_design_01/gblnav_left.gif" alt="XUL" width="5" height="32" border="0" /></a></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
This is another example to the problem ... Code:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript">
function foo(evnt)
{
var e = (window.event) ? window.event : evnt;
alert(e);
e.cancelBubble = true;
}
function bubbletest()
{
alert("I AM BUBBLING");
}
</script>
</head>
<body>
<table id="t" width="50%" border="1" onclick="bubbletest();">
<tr id="tr" onclick="foo(event);">
<td><a href="#" onclick="foo();" id="img"><img src="../../../Site Files/images/css_design_01/gblnav_left.gif" alt="XUL" width="5" height="32" border="0" /></a></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
Regards Anand |
![]() |
| Viewing: ASP Free Forums > Other > Programming Help > Firefox XUL > event bubble problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|