I know this is so basic, but for some reason it’s just not doing anything at all when I click the link, and maybe I’m too overworked and brainfried to spot the issue right now?, lol.
I declared the external js file like this, in the html page (as usual):
<script type="text/javascript" src="js/functions.js" defer="defer"></script>
In the js file I have this code:
function copyToClipboard(text) {
window.prompt ("Copy to Clipboard: Ctrl+C (Windows) or Cmd+C for Mac | Enter", text);
}
Finally, I’m calling the function in my PHP file exactly like this:
<a href="javascript:void(0);" title="Copy ' . $mail . ' to your Clipboard" onClick="copyToClipboard(' . $mail . ');">Copy Address to Clipboard</a>'
When viewing the source of the page, the call looks like this (shorthand):
copyToClipboard(someaddress@domain.com);
When I put an alert call at the very top of the js file, before any functions, it does pop up, so the link to it is fine, but if I put a test alert inside of the actual function, it never pops. My only thought now is, does there need to be a quote visible in the rendered html source on each side of the email address?
Strings in JavaScript have to be quoted.