Tuesday, March 28th, 2006
W3C Range for IE
<p>Jorgen Horstink has started to hack away on a W3C Range implementation for Internet Explorer. An example of its usage is:-
-
<script src="function.prototype.js" type="text/javascript" />
-
<script src="range.js" type="text/javascript" />
-
<script type="text/javascript">
-
window.onload = function () {
-
var sel = new Selection();
-
var range = new Range();
-
-
range.setStart(someTextNode, 4);
-
range.setEnd(someElementNode, 2);
-
sel.addRange(range);
-
}
-
</script>
-
The result will be exactly the same for Internet Explorer as for browsers which implement W3c Range correctly.
Also the decomposition of an Internet Explorer TextRange to a W3c Range is possible. By this, you are allowed to retrieve the startContainer and startOffset properties of the current selection. pretty neat!
Update: Jorgen's original post on this is here. Sorry about missing that the first time, Jorgen.








No link to the actual post?
I believethis is the link to the original post everyone is looking for: http://jorgenhorstink.nl/2006/03/11/w3c-range-in-internet-explorer/
Martin: We had a plugin set up incorrectly. Should be fixed now. Sorry about that.
Looks funny :)
Yeh I agree with Erde
Hi, i’m working on a rich text editor based on jquery and i want to share with you how i made surroundContents and insertNode to work:
considering that this will refer to the current range object.
insertNode: function(node){
if( this.insertNode)
return this.insertNode(node);
var tmpParent = window.document.createElement('div');
tmpParent.appendChild(node);
this.collapse();
this.pasteHtml(tmpParent.innerHTML);
}
surroundContents: function(node){
if( this.surroundContents )
return this.surroundContents(node);
var tmpParent = window.document.createElement('div');
tmpParent.appendChild(node);
node.innerHTML += r.htmlText;
r.pasteHTML(tmpParent.innerHTML);
}
hope this’ll help to improve your code, thanks for your sharing,
malko
Bad regex!
Thanks admin