2011-06-30 59 views

回答

0

下面是在所有主流瀏覽器的功能:

function getSelectionText() { 
    var text = ""; 
    if (window.getSelection) { 
     text = window.getSelection().toString(); 
    } else if (document.selection && document.selection.type == "Text") { 
     text = document.selection.createRange().text; 
    } 
    return text; 
} 
相關問題