View Full Version : Disable to highlight a text on an image
aquilayucca
07-13-2008, 02:43 AM
The following code displays a text "Google" on an image "Yahoo". You can highlight the text by the left button.
<div style="z-index:10;"><img src="http://l.yimg.com/a/i/ww/beta/y3.gif"></div><div style="position:absolute;left:100px;top:40px;z-index:1;">Google</div>
In Google Maps, you can find a text "@2008 Google" in the bottom of the map. When you try to highlight the text as same as the above way, you may find that you cannot do it.
If anybody know how disable to highlight a text on an image, please let me know.
Thank you for your cooperation.
kosstr12
07-13-2008, 03:01 AM
I'm pretty sure that link is inside an application, whether it be Java, Flash, or something different.
binaryWeapon
07-13-2008, 03:15 AM
So basically you need to disable highlighting?
A quick google search (http://www.google.com/search?hl=en&q=disable+highlighting+with+javascript&btnG=Google+Search) turned up this answer to a similar question (source (http://forums.digitalpoint.com/showthread.php?p=7845495)):
Frankly, you could've easily found what you're looking for on Google
Here's something from Dynamic Drive:
Add this script to the HEAD section of your page:
<script type="text/javascript">
/***********************************************
* Disable Text Selection script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
target.style.MozUserSelect="none"
else //All other route (ie: Opera)
target.onmousedown=function(){return false}
target.style.cursor = "default"
}
//Sample usages
//disableSelection(document.body) //Disable text selection on entire body
//disableSelection(document.getElementById("mydiv")) //Disable text selection on element with id="mydiv"
</script>
With the script installed, just call the function disableSelection(target) at the very end of the document with a reference to the element you wish to disable text within. A few examples:
Disable text selection on ENTIRE BODY of page:
<script type="text/javascript">
disableSelection(document.body) //disable text selection on entire body of page
</script>
Disable text selection with DIV with id="mydiv" << you'll probably have different names for your DIVs:
<script type="text/javascript">
var somediv=document.getElementById("mydiv")
disableSelection(somediv) //disable text selection within DIV with id="mydiv"
</script>
Disable text selection within all tables on the page:
<script type="text/javascript">
var alltables=document.getElementsByTagName("table")
for (var i=0; i<alltables.length; i++)
disableSelection(alltables[i]) //disable text selection within all tables on the page
</script>
That is untested, but I'm sure there are others on the that google page if that doesn't work.
aquilayucca
07-13-2008, 04:12 AM
Thank you for your support.
I added the code in my sample. IE7 worked. Unfortunately Firefox3 did not work. Firefox is a target to solve the phenomenon in my application.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.