Selections and documentation (or rather lack of)

G

Gregor Kofler

I've been working on my selection functions a bit, and tried to get any
"official" information about, say, element.getSelectionRange() - the
method has been used by me for quite some time and it is mentioned all
over the web, however, I can't find any ressources on MDC or w3 pointing
out details and/or related methods.

Am I blind, or is this just some hack dating back to Netscape times?

Gregor
 
T

Thomas 'PointedEars' Lahn

Gregor said:
I've been working on my selection functions a bit, and tried to get any
"official" information about, say, element.getSelectionRange() - the
method has been used by me for quite some time and it is mentioned all
over the web, however, I can't find any ressources on MDC or w3 pointing
out details and/or related methods.

Am I blind, or is this just some hack dating back to Netscape times?

Neither one, I hope :) There is no native getSelectionRange() method, at
least not for element objects in the Gecko DOM or the Netscape 4 DOM. There
is however, a window.getSelection() method, which does not originate from
the Netscape 4 DOM, and is not hard to miss on MDC:

<https://developer.mozilla.org/en/DOM/Selection#Methods>
(Main Page, Web development, DOM, Gecko DOM Reference, DOM selection
Reference, Methods)

Vgl.
<http://www.highdots.com/forums/javascript-german/ff-getselectionrange-fuer-input-feld-237706.html>


PointedEars
 
G

Gregor Kofler

Thomas 'PointedEars' Lahn meinte:
Perhaps I should have been more precise: not just element, but form
element, or even more specific input element and textarea element.
Neither one, I hope :) There is no native getSelectionRange() method, at
least not for element objects in the Gecko DOM or the Netscape 4 DOM. There
is however, a window.getSelection() method, which does not originate from
the Netscape 4 DOM, and is not hard to miss on MDC:
<https://developer.mozilla.org/en/DOM/Selection#Methods>
(Main Page, Web development, DOM, Gecko DOM Reference, DOM selection
Reference, Methods)

Then I should have tried "getselection" and not "getselectionrange".
Smart. I always ended up here:

I suppose that's the reason why I couldn't find any documentation about
inputElement.getSelectionRange()

Makes me wonder where I got that from (I'm not /that/ creative). And
makes me wonder even more, why
[..]
if (isHostMethod(elem, "setSelectionRange")) {
elem.setSelectionRange(s, s+len);
}
[..]
works in FF, WebKit based browsers and Opera, with "elem" referencing an
input element.

Gregor
 
T

Thomas 'PointedEars' Lahn

Gregor said:
[...] why
[..]
if (isHostMethod(elem, "setSelectionRange")) {
elem.setSelectionRange(s, s+len);
}
[..]
works in FF, WebKit based browsers and Opera, with "elem"
referencing an input element.

Probably the same reason why `window' works there: trying for compatibility
with existing implementations.

<http://www.faqts.com/knowledge_base/view.phtml/aid/13562>

Another reason could be <http://www.w3.org/TR/html5/editing.html>.

Apropos, it is official now -- XHTML 2 is dead in favor of HTML 5:

,-[from: <http://www.w3.org/>]
|
| XHTML 2 Working Group Expected to Stop Work End of 2009, W3C to
| Increase Resources on HTML 5
|
| 2009-07-02: Today the Director announces that when the <XHTML 2 Working
| Group> charter expires as scheduled at the end of 2009, the charter will
| not be renewed. By doing so, and by increasing resources in the <HTML
| Working Group>, W3C hopes to accelerate the progress of HTML 5 and
| clarify W3C's position regarding the future of HTML. A <FAQ> answers
| questions about the future of deliverables of the XHTML 2 Working Group,
| and the status of various discussions related to HTML. [...]

Whether that is a step in the right direction remains to be seen. However,
ISTM that, again (like with HTML 4.01), quasi-standards have managed to
influence the evolution of HTML more than the W3C process could. Which
makes me question again whether the W3C Process Document and the working
groups' work should undergo a thorough review in order to keep up with the
speed of implementors' innovations and user's demands. For another example,
one really has to wonder why the heck it takes 5 to 7 years for CSS 2.1
(work started in August 2002), and a decade(!) for CSS 3 Selectors (work
started in August 1999!), to mature enough from first Working Draft to even
Candidate Recommendation. CSS 3 Selectors isn't even there yet although for
most features there are two or more interoperable implementations. But I'm
digressing.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top