...

View Full Version : toggle disableselect with radio buttons?



F.N.G.
01-17-2003, 12:03 AM
Hello,

I'd like to know if the following script (or something similar) can be modified to use "on" and "off" radio buttons to toggle disableselect... preferably loading the page with the "on" button selected.

Thanks for any help:


-----------------------------------------------------------------------------

<script>
function disableselect(){
return false
}
function reEnable(){
return true
}
document.onselectstart=new Function ("return false")
{
document.onmousedown=disableselect
document.onclick=reEnable
}
</script>

-----------------------------------------------------------------------------

ez4ne12c
01-17-2003, 03:49 AM
Looks alot like a script i once saw on Dynamic drive .. what exactly does it do?
ez

F.N.G.
01-17-2003, 03:57 AM
what exactly does it do?


It prevents the highlighting/selection of content, such as text.

cheesebagpipe
01-17-2003, 04:28 AM
Strictly IE.

<html>
<head>

<script type="text/javascript">

function toggle_selectable(bWhich, bClear) {
document.onselectstart.isEnabled = bWhich;
if (bClear) document.selection.empty();
}

document.onselectstart = function() {
return document.onselectstart.isEnabled;
}

document.onselectstart.isEnabled = false;

</script>
</head>
<body>
<hr />
<form>
<input name="toggle_hilite" type="radio"
onclick="toggle_selectable(true)" />content selectable
<input name="toggle_hilite" type="radio" checked="checked"
onclick="toggle_selectable(false, true)" />content unselectable
</form>
<hr />
<h1>This is header 1</h1>
<h2>This is header 2</h2>
<p>This is a paragraph</p>
</body>
</html>

F.N.G.
01-17-2003, 05:03 AM
That works nicely; thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum