Selections and documentation (or rather lack of)

Discussion in 'Javascript' started by Gregor Kofler, Jul 5, 2009.

  1. 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


    --
    http://www.gregorkofler.com
    http://web.gregorkofler.com - vxJS, a JS lib in progress
     
    Gregor Kofler, Jul 5, 2009
    #1
    1. Advertising

  2. Gregor Kofler wrote:
    > 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
     
    Thomas 'PointedEars' Lahn, Jul 5, 2009
    #2
    1. Advertising

  3. Thomas 'PointedEars' Lahn meinte:
    > Gregor Kofler wrote:
    >> 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.


    Perhaps I should have been more precise: not just element, but form
    element, or even more specific input element and textarea element.

    >> 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)


    Then I should have tried "getselection" and not "getselectionrange".
    Smart. I always ended up here:
    <https://developer.mozilla.org/en/XUL/Method/setSelectionRange>

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


    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


    --
    http://www.gregorkofler.com
    http://web.gregorkofler.com - vxJS, a JS lib in progress
     
    Gregor Kofler, Jul 5, 2009
    #3
  4. Gregor Kofler wrote:
    > [...] 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
    --
    var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
    ) // Plone, register_function.js:16
     
    Thomas 'PointedEars' Lahn, Jul 6, 2009
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DJ Dev
    Replies:
    1
    Views:
    425
    Corey O'Mara
    Feb 10, 2004
  2. Larry Bud
    Replies:
    2
    Views:
    258
  3. Jonathan Wood
    Replies:
    1
    Views:
    638
  4. studen771

    LoadPostData and html <select> with multiple selections

    studen771, Sep 22, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    185
    studen771
    Sep 22, 2006
  5. Replies:
    0
    Views:
    108
Loading...

Share This Page