views:

100

answers:

5

Either by double click or move the mouse.

Anyone knows about this?

+1  A: 

I think that you refer to the selectevent. See here: http://www.comptechdoc.org/independent/web/cgi/javamanual/javaevents.html

Konamiman
I mean the entire page,not just textarea or input.
Mask
A: 

Could it be document.getSelection()?

Here's a web page on that subject.

Tubbe
I mean the event,not the content.
Mask
Ah, I see, sorry.
Tubbe
A: 

It's possible to use "onselect", but it works just for form elements (inputs, selects...).

function on_select() {
    alert( "selected" );
}

...

<input name="input" onselect="on_select()">
Ondrej Slinták
A: 

Maybe you can bind a function to document.onmouseup to call document.getSelection()? This is assuming your users use mouse to select the text ;)

document.onmouseup = function() {
  var sel = document.getSelection();
  if (sel.length > 0) {
    alert(sel);
  }
}
Lukman
A: 

In IE only the select event applies to body text as well as form inputs, so would do what you want. IE and WebKit have selectstart which fires when the users starts selecting, which probably won't help you. To detect when the user has made a selection in a cross-browser way you will need to handle both keyup and mouseup events. Even then you won't be detecting selection events such as the user using the "Select all" menu option (usually found in the Edit and right click context menus). The situation is not ideal in current browsers.

Tim Down