tags:

views:

42

answers:

1

Hi,

I'm trying to pick up the selected text of a document in a bookmarklet. How do I implement this?

I got this from the internet. Why does this not work?

javascript: Q=document.selection?document.selection.createRange().text:document.getSelection(); alert(Q);

Thanks!

+2  A: 

You have to select text first. It alerts selected text in the page. If you just put that code in your address bar in alerts null because no text is selected.

apphacker
i did that, didn't work :(
Which browser? Works in Safari.
apphacker
Firefox 3 works too.
Matthew Flaschen
oh it does? doesn't work in chrome. just tried in ff. it works. i guess it doesn't work in chrome.
Thanks for the help!