2008年11月8日土曜日

JavaScriptで選択範囲にある文字列を取得する方法

JavaScriptで選択範囲にある文字列を取得する方法をメモしておきます.
ブラウザによって方法が違うみたいですね.
Internet Explorer
document.selection.createRange().text;
Mozilla Firefox
document.getSelection();
window.getSelection();
Safari
window.getSelection();
Opera
document.getSelection();
JavaScript における選択範囲文字列取得の動向
http://wannabe.sweet-smile.org/ent/eid105.htm

0 件のコメント: