Forum Moderators: open

Message Too Old, No Replies

How to stop Copying whilst allowing Input Forms

This script works but breaks input boxes

         

Angonasec

12:17 am on Apr 26, 2008 (gmt 0)



I'm using a script to prevent select and copy text, it works fine.

However, it also disables input forms used for search and subscription to our newsletter.

Can this script be modified to allow input to text boxes?

Alternatively, can the code used for input boxes be changed to avoid the current script from blocking it?

Here's the current type of code used for input boxes:
input type="hidden" name="list" value="listname"
input type="text" name="to_sub" value="Your Email" size="14" onFocus="if (this.value=='Your Email') this.value='';"

Thanks!

Here's the stop copying script:

/* Disable text select (IE4+, NS6+)
*/
function disableselect(e){
return false
}
function reEnable(){
return true
}
//if IE4+
document.onselectstart=new Function ("return false")
//if NS6
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}

niralsoni

12:30 pm on Apr 30, 2008 (gmt 0)

10+ Year Member



function disableSelection()
{
var target = document;
if(target)
{
if (typeof target.onselectstart!="undefined") //IE route
{
target.onselectstart=function()
{
var src = event.srcElement;
if(src && "INPUT,TEXTAREA".indexOf(src.nodeName.toUpperCase()) > -1) // to allow selection in Input box and texarea
return true;
return false;
}
}
}
}

window.attachEvent("onload",disableSelection)

Angonasec

2:03 am on May 1, 2008 (gmt 0)



Thanks niralosni:

I tired using the code you posted, but it allows copying.

Is there a small error?

Angonasec

1:00 am on May 3, 2008 (gmt 0)



Bump... anyone?

Angonasec

2:02 am on May 6, 2008 (gmt 0)



Bump...