All Scripts (Copy to Clipboard) no longer working (local DB)
Dear forum members.
For years, I have been using Ninox as a library for my tracks, which I plan, perform, and archive for biking and hiking.
There are also many scripts that I implemented to copy a value of a field to the clipboard.
Since one year, the structure was fine and completed and everything was running smoothly. So, I was using a perfect DB to add new records. No fine-tuning, nothing.
This week I added a new field with a new button (copy to clipboard) with the same script, I am using for all other buttons to copy the content of a field to the clipboard.
But when I press the button, nothing happens. I tested all my other “copy to clipboard” buttons, and they no longer work!
Also after changing the script to another script, nothing will be copied.
Am I missing something?
The scripts are:
html("
<button onclick='copyToClipboard(""" +
replace('Tour-Namen_DONE_3', "
", "\n") +
""")'>Kopiere ERLEDIGTEN Tournamen 3</button>
<script>
function copyToClipboard(str) {
var el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
}
</script>")
html("
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<style>
/* Define the style for the button */
.custom-button {
width: 100%!important;
color: rgb(48, 89, 240)!important; /* Text color */
background-color: white!important; /* Background color */
padding: 3px 3px!important; /* Padding for better appearance */
border: 1px solid rgb(86, 110, 177)!important; /* Rounded border with text color */
border-radius: 5px!important; /* Add rounded corners */
cursor: pointer!important; /* Change cursor on hover */
font-weight: 700!important; /* Make the text bold */
}
</style>
</head>
<body>
<button class='custom-button'; onclick='copyToClipboard(""" +
replace('Tour-Namen_DONE_3', "
", "\n") +
""")'>Kopiere ORDNER Name für MyTracks</button>
<script>
function copyToClipboard(str) {
var el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
}
</script>
</body>
</html>")
1 reply
-
For security reasons, browsers enforce a very short delay between the user’s last explicit action (such as clicking a button) and the execution of a clipboard copy command. This is intended to prevent scripts from copying content without the user’s knowledge.
Therefore, to ensure the copy operation works properly, the call to the copy function must occur immediately after the user action, without any intermediate processing that could introduce a delay—such as querying a database or performing a complex calculation.
If you suspect that Ninox is causing a delay, I recommend testing your code by temporarily replacing the dynamic content with a hardcoded text string in your JavaScript. This will help you determine whether the issue is related to processing time or something else.
Content aside
- yesterdayLast active
- 1Replies
- 23Views
-
2
Following