Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- selectedText = document.selection?document.selection.createRange().text;
- var userSelection;
- if (window.getSelection)
- userSelection = window.getSelection();
- else if (document.selection) // should come last; Opera!
- userSelection = document.selection.createRange();
- var rangeObject = getRangeObject(userSelection);
- function getRangeObject(selectionObject) {
- if (selectionObject.getRangeAt)
- return selectionObject.getRangeAt(0);
- else { // Safari!
- var range = document.createRange();
- range.setStart(selectionObject.anchorNode, selectionObject.anchorOffset);
- range.setEnd(selectionObject.focusNode, selectionObject.focusOffset);
- return range;
- }
- }
- ...
Add Comment
Please, Sign In to add comment