O
ofirpicazo
Hi, my problem is that IE doesn't seem to do what it's supposed to, so
I hope u guys can give me a hand.
The code below is supposed to make text editable whenever it's clicked,
and it works, the problem is that IE doesn't set the onClick attribute
back to what I tell it to, at least it doesn't do anything if you click
on the text again, as opposed to what Firefox does, FF works!.
I put an alert on the onBlur event to see if IE sets the attribute back
and the weird thing is that it tells me it has done it, but it doesn't
work, it's weird, I hope u guys can help me out with this.
Thanks,
-Ofir
My code:
----------------
<html>
<head>
<title> New </title>
<script language="JavaScript" type="text/javascript">
function doEdit(it) {
var oldValue = it.innerHTML;
it.innerHTML = '<input type="text" value="'+oldValue+'"
onBlur="doUpdate(this.parentNode, this.value);">';
it.removeAttribute('onClick'); // For Mozilla
it.onclick = ''; // For IE
}
function doUpdate(field, value) {
field.innerHTML = value;
field.setAttribute('onClick', 'doEdit(this)'); // For Mozilla
field.onclick = 'doEdit(this)'; // For IE
alert(field.getAttribute('onClick'));
}
</script>
</head>
<body>
<span onClick="doEdit(this)" style="padding:5px;border:1px solid
Gray;">Edit this</span>
</body>
</html>
I hope u guys can give me a hand.
The code below is supposed to make text editable whenever it's clicked,
and it works, the problem is that IE doesn't set the onClick attribute
back to what I tell it to, at least it doesn't do anything if you click
on the text again, as opposed to what Firefox does, FF works!.
I put an alert on the onBlur event to see if IE sets the attribute back
and the weird thing is that it tells me it has done it, but it doesn't
work, it's weird, I hope u guys can help me out with this.
Thanks,
-Ofir
My code:
----------------
<html>
<head>
<title> New </title>
<script language="JavaScript" type="text/javascript">
function doEdit(it) {
var oldValue = it.innerHTML;
it.innerHTML = '<input type="text" value="'+oldValue+'"
onBlur="doUpdate(this.parentNode, this.value);">';
it.removeAttribute('onClick'); // For Mozilla
it.onclick = ''; // For IE
}
function doUpdate(field, value) {
field.innerHTML = value;
field.setAttribute('onClick', 'doEdit(this)'); // For Mozilla
field.onclick = 'doEdit(this)'; // For IE
alert(field.getAttribute('onClick'));
}
</script>
</head>
<body>
<span onClick="doEdit(this)" style="padding:5px;border:1px solid
Gray;">Edit this</span>
</body>
</html>