By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,513 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

de-selecting text on a page

P: n/a
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.

Dec 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"mitch" <mg***@kronos.com> wrote in news:1134403410.377839.140070
@f14g2000cwb.googlegroups.com:
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....
Dec 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.