+ Start a Discussion
Shavi DabgotraShavi Dabgotra 

Copy to clipboard functionality is not being working

Hi Everyone!

I want a copy to clipboard functionality using visualforce page. 
I used the following example as: 

<apex:page title="Clipboard Test" >
<apex:messages />
    <script language="JavaScript">
        function ClipBoard(copytextid, holdtextid){
        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
          // Highlight the content
          // Execute the copy command
          // Remove the input from the body
    <apex:pageblock >
    <apex:form >
        <apex:outputpanel ID="copytext" STYLE="height:150;width:162;background-color:pink">
            <p style="border-style: dashed;" class="borderclass">
                Hi Azure Admin,<br/><br/>

                I'm setting up a SharePoint integration with Salesforce using sFiles. Please create a new Azure App Registration using the 
                <span style="color:rgb(63,137,143);"><b>Redirect URI:</b></span> <br/>
                <a href="https://www.google.com">https://www.google.com </a> <br/><br/>

                Please follow the instructions here: <br/><br/>
                Finally, please provide me with the following information:<br/><br/>
                - Azure Application (client) ID:<br/>
                - Azure Directory (tenant) ID:<br/>
                - Application Client Secret:<br/>


        <apex:inputtextarea ID="holdtext" STYLE="display:none;"></apex:inputtextarea>
        <apex:commandbutton onClick="ClipBoard('{!$Component.copytext}', '{!$Component.holdtext}');" rerender="copytext" value="Copy to Clipboard"/> 

But the problem is that, the html tags are also copied that shouldn't be coiped. 

Could you please help me in this. 

Thank you so much! 

ANUTEJANUTEJ (Salesforce Developers) 
Hi Shavi,

>> https://salesforce.stackexchange.com/questions/167142/copy-to-clipboard-in-visualforce

This link has an example of a copy to the clipboard you can try checking this.

>> https://salesforce.stackexchange.com/questions/2133/remove-visualforce-autogenerated-html-tags

The above link shows a way to remove HTML tags you can try checking this as well.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.