May 19, 201214 yr any ideas on how i can mage the below javascript worki in IE it works in all non IE Browsers function changeHeading(heading) { var range = window.frames['textEditor'].getSelection().getRangeAt(0); var newNode = document.createElement(heading); range.surroundContents(newNode); } Thank you
May 20, 201214 yr Author it seems ie does not support range although this can be worked arround, the problem seems to be finding the content of the iframe in IE Browsers the following will not work in Iframes in IE <iframe name="textEditor" id="textEditor" width="908" height="400"></iframe> $("#textEditor").contents().find('body').html();
May 20, 201214 yr It's been a long time since I've played with iframes, but have you tried something like this: window.frames['textEditor'].window.document.body.innerHTML It might be missing the <body> itself but I think that will give you the contents.
May 20, 201214 yr Author I have a WYSIWYG working in all browsers including adding h tags when using the execCommand for headers it only works in Firefox so i needed a way around this http://quirksmode.org/dom/execCommand.html code below if it helps some one function changeHeading(heading) { if($.browser.msie && $.browser.version == 7 || $.browser.version == 8 || $.browser.version == 9) { Selection = window.frames['textEditor'].document.selection.createRange().htmlText; window.frames['textEditor'].document.selection.createRange().pasteHTML("<"+heading+">"+Selection+"</"+heading+">") } else { var range = window.frames['textEditor'].getSelection().getRangeAt(0); var newNode = document.createElement(heading); range.surroundContents(newNode); } } Thank you Edited May 20, 201214 yr by ELITE
Create an account or sign in to comment