Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with window.getSelection on FF and Opera

Status
Not open for further replies.

Olbaltums

Technical User
Joined
Dec 18, 2007
Messages
1
Location
LV
First I’m sorry for mistakes that I will write – I know English very bad :) but I hope you will understand my question.

I write a simple JavaScript code:

var userSelection;
if (window.getSelection) {
userSelection = window.getSelection();
alert(userSelection + ' Mozzila, Opera');
}
else if (document.selection) { // should come last; Opera!
userSelection = document.selection.createRange();

var selectedText = userSelection;
if (userSelection.text)
selectedText = userSelection.text;

alert(selectedText + ' IE');
}

but problem is that my selected text show only Internet Explorer, but Fire Fox and Opera don’t and I don’t understand why. Can someone help me?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top