2010-08-18 117 views
1

據我所知,IE有一個全字選擇功能,人們經常想要關閉它。瀏覽器全字選擇

我想要相反。

我想自動擴展選擇以在所有瀏覽器中完成單詞。其實,目前來說,我並不在乎IE(但我最終會)。

任何人都知道這個解決方案嗎?

謝謝。

+0

「IE瀏覽器有一個完整的字選擇功能」它確實? – NullUserException 2010-08-18 20:16:48

+0

@NullUserException,我正在回答這個問題,這個問題在Google中是「全文選擇」的第一名。我不知道(或者不在乎)是否是真的。 http://superuser.com/questions/28714/smart-word-selection-in-ie-how-to-disable – harpo 2010-08-18 20:18:21

回答

1

通過使用選擇的修改方法和mousemove事件,您也許能夠在WebKit中執行某些操作(and apparently Firefox 4)。然而,要正確使用它可能會非常棘手:您需要考慮何時適合擴展選擇。

下面是一個使用modify法的一個很簡單的例子:

<p>A paragraph with some nice text in it</p> 

<script type="text/javascript"> 
    function expandSelection() { 
     var sel; 
     if (window.getSelection) { 
      sel = window.getSelection(); 
      if (sel.modify) { 
       sel.modify("extend", "forward", "word"); 
      } 
     } 
    } 
</script> 

<input type="button" onclick="expandSelection();" value="expand"> 
+1

謝謝......這並不像我想象的那麼糟糕。即使獲得支持,我也很難得到我所追求的,但這看起來像我現在可以做的最好的。 – harpo 2010-08-19 00:23:23