Web page Special Effects event binding method and compatible IE FF solution
var t = document.getElementById ("Tab1");
T.onclick = function tst () {
Alert (")";
}
The second method
var TB = document.getElementById ("Tab1");
if (Window.addeventlistener) {//Mozilla, Netscape, Firefox
Td_value.addeventlistener (' Click ', alert (' One '), false);
Td_value.addeventlistener (' Click ', Alert (' '), false);
else {//IE
Td_value.attachevent (' onclick ', function () {alert (' 21 ');});
Td_value.attachevent (' onclick ', function () {alert (' 2 ' 2);});
} ]
JS event events in IE, FF compatibility issues
1, window.event
ie: there are window.event objects
FF: no Window.event object. You can pass an event object to a parameter of a function.
Such as:
The code is as follows:
<input type= "button" onmousemove= "Showdiv (event);" event does not need to be quoted
function Showdiv (event)
{
var event=window.event| | Event
Event.clientx;
Event.clienty;
}
JavaScript Event Binding issues
Child page HTML:
The code is as follows:
<input type= "checkbox" name= "Check" onclick= "Checkedbox (This)" value= "a"/>
Sub-page JS:
The code is as follows:
function Createioc (text,value) {
var o = document.createelement ("a");
O.id = value;
O.href = "#";
O.classname = "C";
O.style.border = "2px solid red";
O.style.width = "250px";
O.style.height = "30px";
O.style.display = "block";
o.innerhtml = "<table><tr><td>" + text + "</td><td></td></tr></table> ';
O.setattribute ("onclick", "Iocclick ()");
return o;
}
function Iocclick () {
Alert (' OK ');
}
function Checkedbox (box) {
Window.parent.document.getelementbyid ("Kdks_panel"). AppendChild (Createioc (' 1 ', ' 2 '));
}
Parent-HTML:
The code is as follows:
<div id= "Kdks_panel" ></div>