[Project_owners] How to get selected text (Solved it)

Neil neil at parkwaycc.co.uk
Sat Mar 20 01:45:21 EST 2004

Jaap A. Haitsma wrote:

>>>selection = focusedWindow.__proto__.getSelection.call(focusedWindow).toString();
>>I wondered why you messed around with __proto__, but even
>>nsContextMenu.js does it, sigh...
>I also found this __proto__ quite funky but saw that it was used in the mozilla code as well.
>Do you know the reason why it's being used?
<html><head><script>function getSelection() { return "fooled you!"; 

Of course that doesn't work in this case:
window.__proto__.getSelection = function getSelection() { return "fooled 
you too!"; }

"getSelection").call(focusedWindow) works, but is wordy...

new XPCNativeWrapper(focusedWindow, "getSelection()").getSelection() 
also works, if the right JS file is included.

My preference would be to have a new function 

More information about the Project_owners mailing list