473,396 Members | 1,766 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,396 software developers and data experts.

How to turn browser text-hilighting back on after disabling

I'm working on some drag-n-drop javascript code for a web app, where the company requires all the users to be on Win XP, using IE 6 (so I don't care about cross-browser compatibility - lucky me!)

I've got the d-n-d code working, and I found code to use to turn off text selection while an object is being moved (which was just plain ugly.) However, I can't figure out how to turn text selection back ON after the object is dropped.

The code to stop the browser from selecting text is done like this:
Expand|Select|Wrap|Line Numbers
  1. document.onselectstart = new Function ("return false");
  2.  
Is there a way for me to first save what document.onselectstart's function was set to? Like a getFunction(document.onselectstart)? OR, does someone know what the function is initially set to - or where I could find a reference that might have it?
Oct 11 '06 #1
1 1756
Oh Jay Why, you simpleton.

Its as easy as creating a temporary function holder, any variable will do. Before setting the document to not hilight, just set your temp variable to the old function. When you're done, just set the documents onselectstart event to your temp var.

Here's some code, in case you're too daft to understand.
Expand|Select|Wrap|Line Numbers
  1. // create your var:
  2. var tempFunctionHolder;
  3.  
  4. // in your drag start code, copy the function to your temp var, then 
  5. // overwrite the select text function:
  6. tempFunctionHolder = document.onselectstart;
  7. document.onselectstart = new function(return false);
  8.  
  9. // when the object is dropped, put things back:
  10. document.onselectstart = tempFunctionHolder;
  11.  
Welcome to coding for Kindergartners!

Sheesh... staring at a screen too long and made a problem more difficult than it was...
Oct 12 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Csaba Gabor | last post by:
I'm not talking javascript hara-kiri here. I've got a database of web pages or snippets I've created and I'd like to display them in a table. So on my server (in PHP) I take all the files, and...
6
by: ok | last post by:
I tried escape, but it is only good for the special ones like : / ' space etc. I want to turn every charactor into %xx then document.write them. I wonder if i can double % them so I can turn @...
2
by: scorp7355 | last post by:
I was wondering if there is some other way to turn autocomplete off besides using "autocomplete=off", using a meta tag or something similar. It would be great if there is some way to turn it off...
3
by: Don | last post by:
Setting: chruch multimedia computer and projection system, with 2 display monitors. The projector is connected to monitor #2. Is there some way using JavaScript I can display a ".jpg" picture...
4
by: Robert Strickland | last post by:
I wish to turn off browser caching through some meta tags. Note the following: <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="-1"> <META...
2
by: Craig G | last post by:
is there a way to distinguish whether a client is using IE or Netscape? is there some sorta check i can run on the Page_Load event? or where would be the best place to do this? Cheers, Craig
9
by: WRH | last post by:
Hello I am new to asp but I made some Jscript functions which work fine. The functions contain some strings used as a registration key for some apps. It is important that these strings not be...
2
by: FredMorstatter | last post by:
I have made a web site that works with both JScript on and off in every browser ...except Opera. I was wondering if there was some way to, upon detection of an Opera browser, turn off JScript on the...
5
by: Mufasa | last post by:
We want to keep track of what OS/Browser people are using for our website. How can I find that out so that I can write it to a DB ? I know how to get it into the DB; I just need to know how to get...
9
by: William Krick | last post by:
I'm currently using the following custom Stylish style sheet in Firefox 2.0.0.11... *{ color: black !important ; background: none !important; background- color: white !important } a:link {...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.