JavaScript: ã¯ãã¹ãã©ã¦ã¶ãªselectionStart/selectionEnd
Mozillaã§å®è£ ããã¦ããselectionStart/selectionEndãIEã§ã使ããããã«ãããSelection.jsãå ¬éãã¾ããã
IEã®TextRangeãªãã¸ã§ã¯ãã¯ã
- range.textãæ¸ãæããã¨é¸æç¯å²æ«å°¾ã®æ¹è¡ãæ¶ãã¦ãã¾ãã
- é¸æç¯å²ã®åå¾ã®ã³ã³ãã¯ã¹ããè¦ã¦å¦çãè¡ãã®ãé£ããã
ã®ãããªä½¿ãã«ããç¹ãããã¾ãã
ããã¯ãHTMLã®æ¸ãæãã§ã¯åé¡ã«ãªããªãããããã¾ããããããã¹ãã¨ãªã¢å ã®æååãæ¸ãæããå ´åã«ãã£ãããªåé¡ãå¼ãèµ·ããã¾ã*1ã
ä¸æ¹ãMozillaã®selectionStart/selectionEndã¯ãtextarea.valueã«å¯¾ããæååæä½ã¨ãã¦å®è£ ã§ãããããä½è¨ãªå¿é ãè¦ãã¾ããã
ã¨ããããã§ãã¯ãã¹ãã©ã¦ã¶ãªselectionStart/selectionEndãå®ç¾ããSelection.jsãä½æãã¾ãããIEã§ã¯ã
- ããã¹ãã¨ãªã¢ã«å«ã¾ããªããã¼ã«ã¼æååãä½æã
- range.text = ãã¼ã«ã¼ + range.text + ãã¼ã«ã¼
- indexOfã§ãã¼ã«ã¼ä½ç½®ãåå¾ã
- ããã¹ãã¨ãªã¢ã®å 容ãå ã®ããã¹ãã«æ»ãã
ã®ããã«ãã¦é¸æç¯å²ã®ããã¹ãã¨ãªã¢å ã®ä½ç½®ãåå¾ãã¦ãã¾ãã
ææ°ã®Operaã§ãåãã¾ããSafariã¯ä»ã®ã¨ãã使ããªãã¨æãã¾ãã
åè
- http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_textrange.asp
- http://www.teria.com/~koseki/memo/javascript/selection_test.html
*1:ã¯ã¦ãªã¦ã¼ã¶ã®æ¹ã¯ããã¤ã¢ãªã¼ç·¨éãã©ã¼ã ã®ä¸ã«ä¸¦ãã§ãããã¿ã³ã使ãã¨ãé¸æç¯å²æ«å°¾ã®æ¹è¡ãæ¶ãã¦ãã¾ãç¾è±¡ãªããã確èªã§ããã¨æãã¾ãã