You need to sign in to do that
Don't have an account?
Kalyan Babu D
how to copy a param field value to clipboard
Hi everyone,
I am new to salesforce,actually i had param field with value as some URL.Now i need to copy that url on ClipBoard by using a button Copy.Can any one please help me out.Thanks in advance.
This is my vf page.
<apex:page controller="one">
<apex:messages />
<script language="JavaScript">
function ClipBoard(copytextid){
copyToClipboard(copytextid);
}
function copyToClipboard(elementId) {
// Create an auxiliary hidden input
var aux = document.createElement("input");
// Get the text from the element passed into the input
aux.setAttribute("value", document.getElementById(elementId).innerHTML);
// Append the aux input to the body
document.body.appendChild(aux);
// Highlight the content
aux.select();
// Execute the copy command
document.execCommand("copy");
// Remove the input from the body
document.body.removeChild(aux);
}
</script>
<apex:form >
<apex:pageBlock id="one">
<apex:pageBlockSection >
<apex:commandButton value="Generate" reRender="one">
<apex:param name="RURL" value="{!$Page.Pagee}" assignTo="{!accid}"/>
</apex:commandButton>
</apex:pageBlockSection>
<apex:pageBlockSection >
Your Referral Link<apex:inputText id="copyText" value="{!accid}"/>
<apex:pageBlockSectionItem >
<apex:commandbutton onClick="ClipBoard('{!$Component.copytext}');" rerender="one" value="Copy to Clipboard"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
I am new to salesforce,actually i had param field with value as some URL.Now i need to copy that url on ClipBoard by using a button Copy.Can any one please help me out.Thanks in advance.
This is my vf page.
<apex:page controller="one">
<apex:messages />
<script language="JavaScript">
function ClipBoard(copytextid){
copyToClipboard(copytextid);
}
function copyToClipboard(elementId) {
// Create an auxiliary hidden input
var aux = document.createElement("input");
// Get the text from the element passed into the input
aux.setAttribute("value", document.getElementById(elementId).innerHTML);
// Append the aux input to the body
document.body.appendChild(aux);
// Highlight the content
aux.select();
// Execute the copy command
document.execCommand("copy");
// Remove the input from the body
document.body.removeChild(aux);
}
</script>
<apex:form >
<apex:pageBlock id="one">
<apex:pageBlockSection >
<apex:commandButton value="Generate" reRender="one">
<apex:param name="RURL" value="{!$Page.Pagee}" assignTo="{!accid}"/>
</apex:commandButton>
</apex:pageBlockSection>
<apex:pageBlockSection >
Your Referral Link<apex:inputText id="copyText" value="{!accid}"/>
<apex:pageBlockSectionItem >
<apex:commandbutton onClick="ClipBoard('{!$Component.copytext}');" rerender="one" value="Copy to Clipboard"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>