Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Not to copy text from a web page

0 views
Skip to first unread message

Sillu

unread,
Mar 1, 2007, 7:50:07 AM3/1/07
to
I'ld like to create a web page, from which no one can select the text
simply, copy frm there n paste at another location. In simple means,
i'ld like to stop copy process from my web page. Plz suggest
JavaScript code for this purpose.

RobG

unread,
Mar 1, 2007, 7:57:09 AM3/1/07
to

Impossible. The following FAQ items are in regard to script, but the
same holds for any other content in the page - if you publish it on
the web, it can be saved locally:

<URL: http://www.jibbering.com/faq/#FAQ4_1 >
<URL: http://www.jibbering.com/faq/#FAQ4_5 >

<FAQENTRY>
Perhaps the items on page protection can be rolled into one, and be in
regard to page content in general as well as just for script
</FAQENTRY>

--
Rob

Tom Cole

unread,
Mar 1, 2007, 8:17:28 AM3/1/07
to

Wouldn't it at least make it a lot more difficult if the body of a
document had only a single div element and the actual page contents
were retrieved through an Ajax call and appended to the div node? A
view source request would then only show the div (unless you had
something like the Firefox developer toolbar which will show generated
source).

Evertjan.

unread,
Mar 1, 2007, 9:09:54 AM3/1/07
to

Yes, if you were not able to type or copy in the IE address bar:

javascript:w=window.open('');w.document.write(document.body.innerText);
void 0

[beware of linebreaks]

Please Tom and Sillu, accept what is known for years, that what you
publish on the web is available on the web, also for copying.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

plemon

unread,
Mar 1, 2007, 1:34:46 PM3/1/07
to
> (Please change the x'es to dots in my emailaddress)- Hide quoted text -
>
> - Show quoted text -

the only full proof way is to make them images

Randy Webb

unread,
Mar 1, 2007, 4:49:21 PM3/1/07
to
plemon said the following on 3/1/2007 1:34 PM:

<snip>

> the only full proof way is to make them images

Pure unadulterated garbage advice.
To prove your point, you are welcome to provide a test page as a proof
of concept and I will copy your text for you.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Evertjan.

unread,
Mar 2, 2007, 3:19:02 AM3/2/07
to
Randy Webb wrote on 01 mrt 2007 in comp.lang.javascript:

> plemon said the following on 3/1/2007 1:34 PM:
>
> <snip>
>
>> the only full proof way is to make them images

"fool" proof?

Kings II 17:10: "And they made them Images ..."

> Pure unadulterated garbage advice.
> To prove your point, you are welcome to provide a test page as a proof
> of concept and I will copy your text for you.

Even without going for a technical solution,
keyboards are cheap these days.

dd

unread,
Mar 2, 2007, 5:07:58 AM3/2/07
to

You can't make it impossible. If it gets into your
browser as text (and not an image) then it's available
in so many ways (browser cache, view source, network
trace, file-save html page etc etc. So you really can't
prevent it in any fool-proof way. Even if you made it
an image, a basic graphics package can read it with an
OCR scan.

I have visited sites that do make attempts to stop
the simple users from doing it though. Some sites
try to catch the keypresses (control-C), or try to
detect attempts to highlight the text (capturing the
mouse drag events), or detecting the right-click
where people are trying to select "Copy".

It's probably not worth it though. The simple users
aren't going to do anything useful with your text.
The advanced users can get around whatever you do.

Randy Webb

unread,
Mar 2, 2007, 9:37:33 AM3/2/07
to
Evertjan. said the following on 3/2/2007 3:19 AM:

> Randy Webb wrote on 01 mrt 2007 in comp.lang.javascript:
>
>> plemon said the following on 3/1/2007 1:34 PM:
>>
>> <snip>
>>
>>> the only full proof way is to make them images
>
> "fool" proof?
>
> Kings II 17:10: "And they made them Images ..."
>
>> Pure unadulterated garbage advice.
>> To prove your point, you are welcome to provide a test page as a proof
>> of concept and I will copy your text for you.
>
> Even without going for a technical solution,
> keyboards are cheap these days.
>

Precisely :-)

Jim Land

unread,
Mar 2, 2007, 11:23:15 PM3/2/07
to
"Sillu" <madhotr...@gmail.com> wrote in news:1172753406.720298.46880
@v33g2000cwv.googlegroups.com:

[Disclaimer: As others have pointed out, there is no way to absolutely
stop a user from copying the text from a page on the web.]

However, you just want to stop a user from using a mouse to select and
copy text on a web page. This is possible. Just make it impossible to
use the mouse to select text.

I ran across it here:
http://www.snopes.com/politics/soapbox/rooney4.asp
The text on that page is just ordinary text, but it can't be selected in
FF and IE.

Their method, simplified, looks like this:

if (typeof document.onselectstart!="undefined") {
document.onselectstart=new Function ("return false");
}else{
document.onmousedown=new Function ("return false");
document.onmouseup=new Function ("return true");
}

Richard Cornford

unread,
Mar 3, 2007, 6:31:46 AM3/3/07
to
Jim Land wrote:
<snip>

> [Disclaimer: As others have pointed out, there is no way to
> absolutely stop a user from copying the text from a page on
> the web.]
>
> However, you just want to stop a user from using a mouse to
> select and copy text on a web page. This is possible.
> Just make it impossible to use the mouse to select text.

It is not possible to make it _impossible_ for the user to select text
and copy it.

> I ran across it here:
> http://www.snopes.com/politics/soapbox/rooney4.asp
> The text on that page is just ordinary text, but it can't
> be selected in FF and IE.
>
> Their method, simplified, looks like this:
>
> if (typeof document.onselectstart!="undefined") {
> document.onselectstart=new Function ("return false");
> }else{
> document.onmousedown=new Function ("return false");
> document.onmouseup=new Function ("return true");
> }

Apart from using a browser that allows javascript execution to be toggled
on and off with a keypress, a simple javascript URL will defeat that. For
IE, for example, a simple:-

javascript: void (document.onselectstart = null);

typed into the address/location bar followed by pressing the return key
will make it possible (even trivial) to select and copy text from the
browser (and that is without even considering acts such as pulling the
source files from the browser's cache and copying the text from those).

Richard.

0 new messages