473,803 Members | 2,913 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to disable text selection with addEventListene r?

example:

function disableText() { return false; }

document.addEve ntListener("mou sedown", disableText, false);

i search many examples that use document.onmous edown = sidableText,

so, how to disable text selection with addEventListene r? thanks

Jul 23 '06 #1
2 2623


mask wrote:

function disableText() { return false; }

document.addEve ntListener("mou sedown", disableText, false);
function disableText (evt) {
if (typeof evt.preventDefa ult != 'undefined') {
evt.preventDefa ult();
}
}

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '06 #2
>
function disableText (evt) {
if (typeof evt.preventDefa ult != 'undefined') {
evt.preventDefa ult();
}
}

--

Martin Honnen
http://JavaScript.FAQTs.com/
thank you!

is there anyway for attachEvent with returnValue?

it's my code:

function returnFalse(ev) {
if (ev.preventDefa ult) {
ev.preventDefau lt();
} else {
window.event.re turnValue = false;
}
}

but it's doesn't work. anyone have good idea? thanks

Jul 23 '06 #3

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

Similar topics

1
12141
by: yair | last post by:
hey all i have a page with a table, and when the user doubleclicks a row in it, a window is opened. The problem is, if he doubleclicked a text in the row, it's becoming selected. what i want is to disable the selection upon doubleclicking, but no the selection at all (so that the user can still just use the mouse to select some text in the table). is there a javascript command that can disable the selection currently highlighted? thanks
3
7172
by: kj | last post by:
Is there any way to disable text selection in a web page (or at least render it invisible to the user)? If there is a way to control how selected text and its background are rendered, then the desired effect could be achieved by setting these parameters to match those of regular text. In this way, even if text was selected, the user would not see that it was. Thanks!
20
47179
by: kj | last post by:
Is there any way to disable text selection in a web page (or at least render it invisible to the user)? If there is a way to control how selected text and its background are rendered, then the desired effect could be achieved by setting these parameters to match those of regular text. In this way, even if text was selected, the user would not see that it was. (I thought that this is something that may be controlled through css, but I...
4
6993
by: Grant Schenck | last post by:
I want to append text to the end of a text box. If the cursor is currently at the end I just want to append it and have the normal scrolling take place if needed. However, if the selection isn't at the end of the text box I want to append the text but WITHOUT changing the selection or scrolling the text. I can easily tell if the selection is at the end or not. However, I haven't found away to prevent the scrolling when I AppendText.
5
3312
by: Sehboo | last post by:
In my application, there are lot of processes which take several seconds. What we want is that once user clicks on a button (or link or whatever) and while we are processing that request, we don't want user to do anything else on the page. We want to disable everything. I have following javascript on all of my pages (which is supposed to work), but it doesn't work. <script language="JavaScript"> function ignoreinput() { return false;
8
8748
by: sneddo | last post by:
Ok I am trying to do the above, I have got a script that will restrict the length but it requires the user to enter the field and hit a key, before it will work. This would normaly be find, but the title field gets its information from a previouse page so its value can easily be over 40 chars. (I can not restrict the length on the previouse page.) The major dificulty is that there is no form on the aspx page, and I do not have access to...
2
1822
by: sourabhmca | last post by:
Hi Friend. I have used a frame inside the html page where in I am displaying the content of other html page.. I want to disable text selection of the content inside the frame.. Can you please show me how to implement "disable text selection" script on such a page. Thanx and Regards, Sourabh
3
3247
by: Venturini | last post by:
I am trying to put together a web page where the customer makes choices of products and is then given a total. I am extremely new to Javascript and have managed to get as far as I have from web searches for scripts and html and adapted them. I need to know the principles of how to disable certain options based on other selections within the form. I have attached my script and html below to help. For example of a customer selects (BASIC...
1
4795
by: Jstyle | last post by:
I have a macro in MS Word that does several hundred find and replace statements. The problem is each time it does a find and replace it prompts me do you want to search from the begining. How do I write into the code to not prompt me each time it does a correction. Below is a small piece of the code. Thanks Sub Macro2() ' ' Macro2 Macro ' ' Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With...
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9566
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10555
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9127
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.