473,326 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

document.selection.empty()

Is there a way to achieve in Firefox (and other browsers) what I achieve in
IE6 with the document.selection.empty()? I want to be able to empty the
selection every time the user clicks a certain area, thus making it
impossible to select any text in that area. Is there a way to clear the
text selection in Firefox?

David
Aug 5 '05 #1
3 10390


David wrote:

I want to be able to empty the
selection every time the user clicks a certain area, thus making it
impossible to select any text in that area.


Well JavaScript in the DOM mostly works on elements and other nodes and
not on "areas" but if you for instance have a <div> element and you want
to prevent that the user selects text inside the <div> element then you
can do that with
<div onselectstart="return false;"
style="-moz-user-select: none;">
<p>Kibology for all.</p>
<p>All for Kibology.</p>
</div>
for IE (with the onselectstart="return false;") and for Mozilla (with
the CSS extension -moz-user-select: none;).
There is no need to try to manipulate/empty the selection with script.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 5 '05 #2
Martin Honnen <ma*******@yahoo.de> wrote:
<div onselectstart="return false;"
style="-moz-user-select: none;">


As chance would have it, I had been wanting to do this very thing as
well, and now I can - thank you!

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Aug 5 '05 #3
Martin Honnen wrote:
Well JavaScript in the DOM mostly works on elements and other nodes and
not on "areas" but if you for instance have a <div> element and you want
to prevent that the user selects text inside the <div> element then you
can do that with
<div onselectstart="return false;"
style="-moz-user-select: none;">
<p>Kibology for all.</p>
<p>All for Kibology.</p>
</div>
for IE (with the onselectstart="return false;") and for Mozilla (with the
CSS extension -moz-user-select: none;).
There is no need to try to manipulate/empty the selection with script.


Ahh, very simple and it does just what I'm wanting, thanks a lot!!

David
Aug 5 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ingvald | last post by:
hi, i've hit a wall regarding php and ms word. what i want is to open a document containing bookmarks, insert text where the bookmarks are, and save. it's working, unless the bookmark is in...
2
by: Mirjana Rakuljic | last post by:
Hi, I need help with transforming XML document. I generate xml document from query using Oracle XSU (DBMS_XMLQUERY) and the document I get is like this: <?xml version = '1.0' encoding =...
1
by: lawrence | last post by:
This PHP function prints out a bunch of Javascript (as you can see). This is all part of the open source weblog software of PDS (www.publicdomainsoftware.org). We had this javascript stuff...
4
by: JE | last post by:
Hi! I am snooping around all sorts of websites and faqs, in search of a way to pick up any selected (mouse-highlighted) text in a HTML page, and store it in a JavaScript variable. I have...
15
by: lawrence | last post by:
Is this the correct way to test for a method before I use it? createRange() is, I believe, an IE only method. function wrapSelectionInTag(selection, tag) { if (document.selection.createRange)...
3
by: svdh2 | last post by:
I have been looking at a problem the entire week in access, I have still not been able to find a solution. Hope that you could maybe tell where to look Concerns the link between Access and Word....
1
by: adam lital | last post by:
Hi, I have word document and i want to replace a specific text with a bookmark using code. Example: in the document i have the text and i want to replace this to a bookmark called ClientName....
6
by: Robert W. | last post by:
I'm building my first major C# program and am try to use best practices everywhere. So I've implemented the "Document/View Model" whereby: - There's a Windows Form, which we'll call "formView" -...
1
by: mrsgwen90 | last post by:
I have an access application with a vba backend and it opens a word document to enter information and then print the word document and should close it. I keep getting an error on the line...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.