PDA

View Full Version : selective select



taith
05-10-2007, 04:12 PM
1) Script Title: Disable Text Selection script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex9/noselect.htm

3) Describe problem: trying to alter the code to disable all, and allow only certain ones... but its not working... anybody got any ideas? disableing works... but enableing wont :confused:


function disablemouse(){
var target=document.body;
if(typeof target.onselectstart!="undefined") target.onselectstart=function(){return false}
else target.onmousedown=function(){return false}
}

function enablemouse(){
this.onselectstart=function(){return true}
this.onmousedown=function(){return true}
}

ddadmin
05-10-2007, 08:51 PM
Do you mean disable select-text inside certain elements on the page only? You can do this already with the script as is. For example:


<div id="mydiv">Text inside this DIV isn't selectable</div>

<p>Text that IS selectable</p>

<script type="text/javascript">
var somediv=document.getElementById("mydiv")
disableSelection(somediv) //disable text selection within DIV with id="mydiv"
</script>