Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

copyToClipboard not working

janed_o_
Beginner
935 Views

I am trying to use Device plugin copyToClipboard but it's not working...test on Android. please someone help. Thank You

below is my code

<!DOCTYPE html>
<html>

    <script src="cordova.js" id="xdkJScordova_"></script>

    <script src="js/app.js"></script>           <!-- for your event code, see README and file comments for details -->
    <script src="js/init-app.js"></script>      <!-- for your init code, see README and file comments for details -->
    <script src="xdk/init-dev.js"></script>     <!-- normalizes device and document ready events, see file for details -->
    <script src="xhr.js"></script>
       
   <script type="text/javascript" src="js/SocialSharing.js"></script>
    
     <script type="text/javascript">
        var onDeviceReady=function(){                             // called when Cordova is ready
           if( window.Cordova && navigator.splashscreen ) {     // Cordova API detected
                navigator.splashscreen.hide() ;                 // hide splash screen
            }
        } ;
        document.addEventListener("deviceready", onDeviceReady, false) ;
    </script>
	
	    	
    
    <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
    

</head>


<body>
    
     <script>
        function openExternal(elem) {
            window.open(elem.href, "_system");
            return false; // Prevent execution of the default onClick handler 
        }
                
         
    </script>
	
 <script>
	//Test for javascript interface "intel.xdk.device.copyToClipboard()".
            function copyToClipboard(text){
                intel.xdk.device.copyToClipboard(text);
            }
</script>
	

<button onclick="copyToClipboard('hello, world');">copyToClipboard</button>

	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
	<script src="js/base.min.js"></script>
</body>

</html>

 

 

0 Kudos
4 Replies
janed_o_
Beginner
935 Views

urgent.....please help

0 Kudos
John_H_Intel2
Employee
935 Views

The intel.xdk.device plugin is being deprecated, so I suggest that you find another Cordova plugin that will do what you are looking for.

That being said, it should work if you have selected that plugin in the project settings-plugins. Is this in App Preview, XDK, or on a built application? What platform?

0 Kudos
janed_o_
Beginner
935 Views

IntelXDK ....Windows 10 ......Android

its not working,,,and there no other plugins.

 

0 Kudos
John_H_Intel2
Employee
935 Views

I copied your code, built an apk, installed on an S4 running android 5.0.1 and it copied the "hello,world" just fine.

I then opened a browser, and pasted it in. It worked as it should.

0 Kudos
Reply