Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to select a node in a range with webkit browsers?
    primarykey
    data
    text
    <p>I'm currently working on a WYSIWYG solution and need a function to correctly select with a range a node (by this I mean the node itself, not only it's content)</p> <p>DOM lvl2 clearly have a function for this <a href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113/ranges.html#Level2-Range-method-selectNode" rel="nofollow">w3.org/ranges</a> and define that </p> <p><code>range.selectNodeContents() // Select the contents within a node</code><br> and<br> <code>range.selectNode() //Select a node and its contents</code></p> <p>The problem is that when selectNode() perfectly work with Firefox or even ie9, it seem to be impossible to achieve with any Webkit browser (at last Chrome and Safari). On Webkit both selectNodeContents() and selectNode() select the node content only (which according to the specs seems to me to be a bug)</p> <p>To make it work I tried to emulate the selectNode() goal by using<br> <code>range.setStartBefore(node);<br> range.setEndAfter(node); </code><br> but the result is still the same, it work everywhere (ie>8 of course) but not on webkit browsers..</p> <p>If you want to try it I made a little jsfiddle with which you can play <a href="http://jsfiddle.net/vooor/PeRpT/" rel="nofollow">here</a> (just open the console and look at the console.warn result which is not the same on webkit :/ )</p> <p>I searched a lot but I can't find a way to actually select a full node on webkit browsers. By miracle would some of you know a way to do it or even just any tip to continue my quest ? :/</p> <p>ps : I know "rangy" lib but I can't use it in my project and ,from what I read in the source, I'm not even sure they deal with that thing anyway :/</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload