<HTML>
<HEAD></HEAD>
<BODY><p>pippo1</p><p>pippo2</p><p>pippo3</p></BODY>
<SCRIPT language="JavaScript">
var sel = window.getSelection();
sel.collapse( document.body, 0 );
sel.extend( document.body, 3 );
</SCRIPT>
</HTML>

This will work only if there are no spaces between tags, or you will have to
count spaces/new lines text nodes too:

<HTML>
<HEAD></HEAD>
<BODY>0 -- this new line is a text node  -- 1
1<p>pippo1</p>2 -- this new line is a text node -- 3
3<p>pippo2</p>4 -- this new line is a text node -- 5
5<p>pippo3</p>6 -- this new line is a text node -- 7
</BODY>
<SCRIPT language="JavaScript">
var sel = window.getSelection();
sel.collapse( document.body, 0 );
sel.extend( document.body, 6 );
</SCRIPT>
</HTML>

will work also.

Henri

"Stefano" <[EMAIL PROTECTED]> a �crit dans le message de
news:[EMAIL PROTECTED]
> Hi
>
> i am writting a wysawyg editor and i have a problem with selection
> i have this case:
>
> <p>pippo1</p>
> <p>pippo2</p>
> <p>pippo3</p>
>
> so i want set focus in pippo1 AND want select all three paragraphs.
> So i have set focus with "select_doc.collapse(x[0].firstChild,0);"
> where x[0] is pointer to first p and then
> select_doc.extend(x[0].parentNode,3); for to select all 3 paragraph
>
> but with thi lines i don't select that i want!!!
> Can you help me?
>
> Thankx stefano
>



_______________________________________________
mozilla-editor mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-editor

Reply via email to