this code will alert the selected text
if (window.getSelection) {
var str = window.getSelection();
}
else if (document.getSelection) {
var str = document.getSelection();
} else if (document.selection && document.selection.createRange) {
var range = document.selection.createRange();
var str = range.text;
} else {
var str = "Sorry, this is not possible with your browser.";
}
alert(str);
part of this code is from
this site
I added some code to make it work for safari
Thursday, February 21, 2008
Subscribe to:
Post Comments (Atom)
4 comments:
Post a Comment