I have a set of HTML elements that I add an onclick event to at
runtime. All it does is get the contents of an element using
innerHTML.
It all works fine in Firefox, but I can't get it to work in IE. No
doubt I have a really simple error.... help!
window.event returns an object, but
window.event.toElement returns null.
A broken (in IE) sample snippet is below:
<html><head><title>Arrgghhh</title>
<script type="text/javascript">
ie = document.all;
function showTxt(e) {
var d = (ie) ? window.event.toElement.innerHTML :
e.target.innerHTML;
alert(d);
}
function addClick(){
document.getElementById('rob').onclick = showTxt;
}
</script>
</head>
<body onload="addClick();">
<p id="rob">here is robs text</p>
</body>
</html>