strange behavior with designMode under IE
Posted on 2006-04-19
I have an iframe.. I want to toggle designMode on and off. I have a function to do it like:
// Save the contents of the iFrame..
var strBody = document.getElementById("e_body").contentWindow.document.body.innerHTML;
// Toggle design mode on/off.
document.getElementById("e_body").contentWindow.document.designMode = bOn ? 'on' : 'off';
// Set the contents back again.
document.getElementById("e_body").contentWindow.document.body.innerHTML = strBody;
This whole function was created in an attempt to get IE to work.. If I just toggle the designMode attribute, in IE all the contents of the iframe will be deleted. So I have this function to store the contents while the mode is being toggled, then set the contents back afterwards. Is this really necessary?
This function actually fails when I try to set the body text back in the last call - oddly if I put an alert box right before it, it seems to work ok!? My guess is that there's some synchronization thing going on in which the mode hasn't been set yet or something?
Any help would be great, I've wasted a lot of time on this,