You know how some websites have that "click to copy this address"?
1) How could I grab the URL using MODx? Does MODx have a variable that does this?
2) How could I make it so when the user clicks the text, it auto-copies, instead of them having to copy it?
This should give you the full URL:
So this (in theory, I haven’t tried it) should copy the link to the user’s clipboard. Not sure if it will work in all browsers (should work in IE). Someone else may know a more generic solution.
<span id="copytext" style="height:150;width:162;background-color:pink">
[~[+id+]~]
</span>
<textarea id="holdtext" style="display:none;">
</textarea>
<button onClick="ClipBoard();">Copy to Clipboard</button>
<script language="JavaScript">
function ClipBoard()
{
holdtext.innerText = copytext.innerText;
Copied = holdtext.createTextRange();
Copied.execCommand("Copy");
}
</script>
EDIT: BTW, that solution doesn’t work outside IE.
I did find a universal solution. Still requires a click on a button to work, although I’m trying to see if I can automate it when they click on the form...
Quote from: zi at May 30, 2008, 06:19 AM
It should be [~[*id*]~] ... notice the asterisk. 
And to get full url, you need to prefix: [(site_url)]. But if you have <base href="[(site_url)]" /> in the <head> section then you don’t need it.
regards.
Oops. Copied that from either the Ditto or Wayfinder docs. If I understand this correctly, my version would work if you’re using either Ditto or Wayfinder because they set up the [+id+] placeholder. Your solution is more generic and therefore much better.
Bob