rejetto forum

Software => HFS ~ HTTP File Server => HTML & templates => Topic started by: d95gas on April 06, 2016, 05:58:56 PM

Title: Disable Right Click in template
Post by: d95gas on April 06, 2016, 05:58:56 PM
Hi All,

Been a while since I have been on, and some fantastic work been done in the that time.

I am hoping someone can point me in the right direction.   I want to be able to disable RIGHT mouse click when the web page for HFS is running, to prevent the users from doing anything than clicking on the file to open/download.

Hoping someone might have an answer.


Thanks
Title: Re: Disable Right Click in template
Post by: rejetto on April 07, 2016, 11:58:02 AM
hi,
you will find the code you need somewhere on google, then
1. ensure it is enclosed within <script> tags
2. go to hfs, in the "virtual file system" box, right clik on the first element (HOME)
3. properties
4. diff template
5. enter this text:
Code: [Select]
[+]
<script>
insert your code here
</script>
Title: Re: Disable Right Click in template
Post by: d95gas on April 07, 2016, 02:08:19 PM
Thanks for the quick reply.

I followed your instructions to the letter posting the code as indicated below.   When I open the site (localhost) it will open the page without anything showing on the page other than the header.

<script language="javascript">
document.onmousedown=disableclick;
status="Right Click Disabled";
Function disableclick(e)
{
  if(event.button==2)
   {
     alert(status);
     return false;   
   }
}
</script>



I am obviously missing the point somewhere :-(


Thanks
Title: Re: Disable Right Click in template
Post by: bmartino1 on April 08, 2016, 01:16:51 AM
http://stackoverflow.com/questions/737022/how-do-i-disable-right-click-on-my-web-page

html code it:

<script language="javascript">

document.addEventListener("contextmenu", function(e){
    e.preventDefault();
}, false);
}
document.onmousedown=disableclick;
status="Right Click Disabled";
Function disableclick(e)
{
  if(event.button==2)
   {
     alert(status);
     return false;   
   }
}
</script>

Jquery will work better with HFS

<script language="javascript">
// With jQuery
$(document).on({
    "contextmenu": function(e) {
        console.log("ctx menu button:", e.which);

        // Stop the context menu
        e.preventDefault();
    },
    "mousedown": function(e) {
        console.log("normal mouse down:", e.which);
    },
    "mouseup": function(e) {
        console.log("normal mouse up:", e.which);
    }
});
</script>
Title: Re: Disable Right Click in template
Post by: d95gas on April 08, 2016, 04:44:48 AM
Tried that and all I get when I load up a page is "Jquery will work better with HFS "


Thanks anyway


Title: Re: Disable Right Click in template
Post by: bmartino1 on April 11, 2016, 03:09:07 AM
that base info, that not a complete code... see the web link provided with info regarding these two codes, that are still ways to "stop this".....

but here is a working html code, you can drop into the different template tab

Code: [Select]
<head>

<script language="javascript">
// With jQuery
$(document).on({
    "contextmenu": function(e) {
        console.log("ctx menu button:", e.which);

        // Stop the context menu
        e.preventDefault();
    },
    "mousedown": function(e) {
        console.log("normal mouse down:", e.which);
    },
    "mouseup": function(e) {
        console.log("normal mouse up:", e.which);
    }
});
</script>

<script language="javascript">
document.addEventListener("contextmenu", function(e){
    e.preventDefault();
}, false);
</script>

</head>

<body>
<p> test, you can't mousr click </p>
</body
Title: Re: Disable Right Click in template
Post by: rejetto on April 24, 2016, 10:21:36 AM
sorry for the long wait, d95gas.
my advice was correct, but a bug in HFS prevented it from working.
It will work in HFS 2.3h

After fixing i tried your code, and found a typo: "Function" must be all lowercase.
Title: Re: Disable Right Click in template
Post by: rejetto on April 25, 2016, 02:56:31 PM
http://www.rejetto.com/forum/hfs-~-http-file-server/2-3h-preview/