Hi guys!
I was wondering how to prevent user of the database to just copy (CTRL +A & CTRL+C) the table on the screen?
I know how to do this in the basic HTML website - but where & what code to put in the AppGini project?
Can I put the CTRL+C blocking script only into: INDEX.HTML?
Below is the link on the CTRL + key blocking script I would use:
https://pastebin.com/qppZugBW
BTW - if you have a better solution (better script) - please post it here - thank you!!!
Prevent user from CTRL+C of the screen...
Re: Prevent user from CTRL+C of the screen...
I'm pretty sure you cannot deny copying completely. You can block keyboard input, sure, but if users cannot use CTRL+C on the keyboard but want the data, there are still enough options like these:
If you need something bulletproof, I think you cannot use HTML in a common browser.
But I'm very interested if someone here has a solution.
From my experience:
Years ago (decades, actually) a customer wanted to share price lists with his customers on the internet but didn't want them to download the lists for later use. He wanted them to always get latest price lists, not outdated ones. Other developer companies failed before, so did we on finding any bulletproof solution in HTML with standard browsers.
- use keyboard or mouse for selecting text, then (right click) context menu item for copying
- in Windows use F10 key, then copy command
- save file as html and open it locally in any text editor. Copy from there.
- show sourcecode (CTRL+U) in browser and copy from there
- open developer tools (F12) and copy table from elements tab (or use inspect element and do the same)
- disable Javascript after page has been reloaded, then use CTRL+C
- take a screenshot + ocr (for example use the OCR tool built into screenshot-tool ShareX)
If you need something bulletproof, I think you cannot use HTML in a common browser.
But I'm very interested if someone here has a solution.
From my experience:
Years ago (decades, actually) a customer wanted to share price lists with his customers on the internet but didn't want them to download the lists for later use. He wanted them to always get latest price lists, not outdated ones. Other developer companies failed before, so did we on finding any bulletproof solution in HTML with standard browsers.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Prevent user from CTRL+C of the screen...
@ jsetzer
Thank you for your feedback!
Yes, I know there are many ways to copy the content of the table in browser - even taking a screen shot is one way which could not be prevented...
Anyways, I want to prevent simple and easy "copy + paste"...
So, I wondering where to put the javascript code (I have put link to the code above)?
In the index.html or index.php... or someplace else?
Guys, I'm open to your suggestions - thank you!
Thank you for your feedback!
Yes, I know there are many ways to copy the content of the table in browser - even taking a screen shot is one way which could not be prevented...
Anyways, I want to prevent simple and easy "copy + paste"...
So, I wondering where to put the javascript code (I have put link to the code above)?
In the index.html or index.php... or someplace else?
Guys, I'm open to your suggestions - thank you!
Re: Prevent user from CTRL+C of the screen...
hooks/header-extras.php
could be a central place. Put javascript code in a <script/>
tag.If you need it for one table or several tables,
hooks/TABLENAME-TV.js
should work. But remember that tables are lazy loaded in table views. Just in case you try to setup a keydown/keypress/keyup event listener on a table directly instead of attaching the listener to the document.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Prevent user from CTRL+C of the screen...
While I haven't ever tried it for myself, a quick browse of Google returned this page with some very elementary jQuery examples (scroll down the page) that should be able to be added to hooks/header-extras.php or hooks/TABLENAME-TV.js to do the job:
"How to Disable Text Selection, Copy, Cut, Paste and Right-click on a Web Page"
https://www.w3docs.com/snippets/javascr ... -page.html
As Jan mentioned, very easy to override so it won't stop anything malicious but it should at least prevent the average user from using those functions (that is assuming the code works).
"How to Disable Text Selection, Copy, Cut, Paste and Right-click on a Web Page"
https://www.w3docs.com/snippets/javascr ... -page.html
As Jan mentioned, very easy to override so it won't stop anything malicious but it should at least prevent the average user from using those functions (that is assuming the code works).
Re: Prevent user from CTRL+C of the screen...
Code: Select all
<script>
$j(document).ready(function() {
//Disable cut copy paste
$j('body').bind('cut copy paste', function(e) {
e.preventDefault();
});
//Disable mouse right click
$j("body").on("contextmenu", function(e) {
return false;
});
});
</script>
Re: Prevent user from CTRL+C of the screen...
Thought I'd better try it myself to save embarrassment, which I now have.
Doesn't seem to work in hooks/header-extras.php for some reason?
But if you add the following snippet to hooks/tablename-tv.js it does work nicely (obviously replace tablename with the actual table name and if the file doesn't exist, create it)
That is for table view only. Same should work for detail view if you add it to hooks/tablename-dv.js
Doesn't seem to work in hooks/header-extras.php for some reason?
But if you add the following snippet to hooks/tablename-tv.js it does work nicely (obviously replace tablename with the actual table name and if the file doesn't exist, create it)
Code: Select all
$j(document).ready(function() {
//Disable cut copy paste
$j('body').bind('cut copy paste', function(e) {
e.preventDefault();
});
//Disable mouse right click
$j("body").on("contextmenu", function(e) {
return false;
});
});
Re: Prevent user from CTRL+C of the screen...
@ peebee & @jsetzer
Thank you guys very much for your detailed and precise answer(s)!
I'll try to implement this over the weekend - I'll let you know on Monday/Tuesday!
Have a great weekend - cheers!
Thank you guys very much for your detailed and precise answer(s)!
I'll try to implement this over the weekend - I'll let you know on Monday/Tuesday!
Have a great weekend - cheers!
Re: Prevent user from CTRL+C of the screen...
Thank you!peebee wrote: ↑2023-02-10 05:24Thought I'd better try it myself to save embarrassment, which I now have.
Doesn't seem to work in hooks/header-extras.php for some reason?
But if you add the following snippet to hooks/tablename-tv.js it does work nicely (obviously replace tablename with the actual table name and if the file doesn't exist, create it)
That is for table view only. Same should work for detail view if you add it to hooks/tablename-dv.jsCode: Select all
$j(document).ready(function() { //Disable cut copy paste $j('body').bind('cut copy paste', function(e) { e.preventDefault(); }); //Disable mouse right click $j("body").on("contextmenu", function(e) { return false; }); });
It worked like a charm!
I'll be so free to contact you peebee and/or jsetzer if I had a paying job regarding online DB "tweeks" and related AppGini stuff!
So, if it's allowed on this forum - I'd ask you two for contact emails - thank you!
Have a great day!