de-selecting text on a page

M

mitch

I'm trying to clear the currently selected
text on a page. This line works from IE:

document.selection.empty();

and this one from Firefox:

window.getSelection().removeAllRanges();

However it seems like neither works with Safari
1.2. In Safari, window.getSelection() is defined but
window.getSelection().removeAllRanges() is undefined.
Any ideas how to do the de-selection on Safari? Thanks.
 
P

Patient Guy

I'm trying to clear the currently selected
text on a page. This line works from IE:

document.selection.empty();

and this one from Firefox:

window.getSelection().removeAllRanges();

However it seems like neither works with Safari
1.2. In Safari, window.getSelection() is defined but
window.getSelection().removeAllRanges() is undefined.
Any ideas how to do the de-selection on Safari? Thanks.


Does it help to create a Range object from your selection and work with
that? On the belief that a Selection object is distinct from a Range
object and some sort of alternate browser-specific reference to a range
just the same....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top