Selection: toString() 方法
Selection.toString() 方法返回由 selection 物件當前表示的字串,即當前選中的文字。
語法
js
toString()
引數
無。
返回值
表示選中的字串。
描述
此方法返回當前選中的文字。
在 JavaScript 中,當一個需要字串的選擇物件被傳遞給某個函式時,此方法會被自動呼叫。
js
alert(window.getSelection()); // What is called
alert(window.getSelection().toString()); // What is actually being effectively called.
規範
| 規範 |
|---|
| Selection API # dom-selection-stringifier |
瀏覽器相容性
載入中…
另見
Selection,它所屬的介面。