[thelist] JavaScript exception caught but no code run in IE.
Josh Endries
josh at endries.org
Sun Mar 19 16:38:20 CST 2006
Hello,
I was playing with some editable table elements and ran into what seems
to me to be a bug in IE (!!!). It's pretty hacky in general I guess, but
it works fine in FF. I have a TD that, when double clicked, turns it's
content into an input tag. onblur runs a validation function (eventually
ajax) and sets the TD's content. IE gets into the doUpdate code, and
throws the exception (removing the try/catch causes an unhandled
exception error), but it never runs the code inside the catch block.
Here's the code:
<html>
<body>
<script type="text/javascript" src="/js/behaviour.js"></script>
<script type="text/javascript">
window.rules = {
'.editable': function(element) {
element.ondblclick = function() {
var newElement = document.createElement("input");
newElement.value = element.innerHTML;
newElement.className = "editable";
newElement.oldValue = element.innerHTML;
newElement.style.width = element.offsetWidth;
newElement.style.height = element.offsetHeight;
newElement.style.border = "0px";
element.innerHTML = "";
element.appendChild(newElement);
Behaviour.apply();
newElement.select();
newElement.focus();
},
element.onblur = function() {
if (element.value) {
var value = element.value;
if (element.parentNode) {
if (element.parentNode.doUpdate) {
try {
element.parentNode.doUpdate(element.value);
} catch (e) {
alert("catch");
if (element.oldValue) {
value = element.oldValue;
}
alert("Error: "+e);
}
}
element.parentNode.innerHTML = value;
}
}
}
},
'.test': function(element) {
element.doUpdate = function(value) {
if (value == "x") {
throw "xcept";
}
}
}
}
Behaviour.register(window.rules);
</script>
<table border=1>
<tr>
<td class="test editable">test</td>
</tr>
</table>
</body>
</html>
Thanks,
Josh
More information about the thelist
mailing list