Creating a simple bookmarklet in javascript

I am trying to match the highlighted text of a document in a bookmarket. How to implement this?

I got this from the internet. Why doesn't it work?

JavaScript: & Alpha; Q = document.selection document.selection.createRange () text :. Document.getSelection (); alert (Q);

Thanks!

0


a source to share


1 answer


First you need to select the text. It alerts the selected text on the page. If you just put this code in your address bar in null alerts because no text is selected.



+2


a source







All Articles