HTML Code for Firefox to Stop Right-Click Copying

  • Context: HTML/CSS 
  • Thread starter Thread starter MartinJH
  • Start date Start date
  • Tags Tags
    Code Firefox Html
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
5 replies · 3K views
MartinJH
Messages
72
Reaction score
2
I realize HTML isn't strictly a 'coding language' or so I've heard.
I have a good friend who has a site he needs to prevent users from 'right clicking and copy'.
Its a guitar tab site and he has spent relentless hours transcribing a band whos songs are far from easy. So to prevent, to a certain degree, unrightful copying he needs the code to prevent this, specifically in Firefox. So if anyone has this or a source, we both would be very grateful.
Thanks
 
on Phys.org
All sorted now.
I thought you needed to call a .js file but you can do it all within html with this code:

Code:
<SCRIPT TYPE="text/javascript">
<!--
//Disable right click script
//visit http://www.rainbow.arch.scriptmania.com/scripts/
var message="Sorry, right-click has been disabled";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
</SCRIPT>
 
You can't. There is nothing you can do to stop an industrious visitor from grabbing stuff from a site, except for not putting it up.

As for that JavaScript, NoScript will bypass that.
 
You were correct in believing that HTML is not a coding language. It bears no real relation to coding languages, it is a "markup language" that has to be interpreted by a browser. It DOES, as you found, allow embedded coding in the form of javascript.
 
MartinJH said:
All sorted now.
I thought you needed to call a .js file but you can do it all within html with this code:

Code:
<SCRIPT TYPE="text/javascript">
<!--
//Disable right click script
//visit http://www.rainbow.arch.scriptmania.com/scripts/
var message="Sorry, right-click has been disabled";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
</SCRIPT>

And how do you prevent someone from saving the entire webpage to disk ?
Like jhae said , you can go only so far to interfere into someone's browser.
The fact that the browser contains the content means that the data is already downloaded to the external party
 
GJBRKS said:
And how do you prevent someone from saving the entire webpage to disk ?
Like jhae said , you can go only so far to interfere into someone's browser.
The fact that the browser contains the content means that the data is already downloaded to the external party
I wouldn't want to waste my time trying to prevent that and has never been a thought :).This is/was not a full attempt to prevent users from unrightfully copying something I must make that clear :).
I haven't said I want to prevent users from saving the entire content, if they want to do that then who can stop them. Above, I have merely said id like to prevent it to a certain degree from users who are not knowledgeable in that aspect.
Its a small measure to reduce the amount of users from directly copying something. I realize it is a waste of time since you can view the source code and grab what you like that way.
I understand there are more script kiddies these days and people who do know what they are doing and are able to get what they want but this isn't there to hinda there progress.
 
Last edited: