Lodius2000 Posted October 11, 2008 Share Posted October 11, 2008 Hi, I know zero js but heres what i got, I wanna copy $id to the clipboard and this isnt working, what am i doing wrong, and is this only for 1 browser, do i need a different method for other browsers? <?php $id = "6228"; print "<script type=\"text/javascript\">\n"; print "var id;\n"; print "id=$id;\n"; print "id.execCommand(\"Copy\");"; print "</script>"; ?> thanks Link to comment https://forums.phpfreaks.com/topic/127938-php-and-js-copy-to-clipboard/ Share on other sites More sharing options...
rochakchauhan Posted October 11, 2008 Share Posted October 11, 2008 Well I dont think you can do that with Javascript alone... many issues... portability, compatibility, security .. try this: function copyToClipboardViaFlash(text) { var flashId = 'flashId-HKxmj5'; var clipboardSWF = 'http://appengine.bravo9.com/copy-into-clipboard/clipboard.swf'; if (!document.getElementById(flashId)) { var div = document.createElement('div'); div.id = flashId; document.body.appendChild(div); } document.getElementById(flashId).innerHTML = ''; var content = '<embed src="' + clipboardSWF + '" FlashVars="clipboard=' + encodeURIComponent(text) + '" width="0" height="0" type="application/x-shockwave-flash"></embed>'; document.getElementById(flashId).innerHTML = content; } Link to comment https://forums.phpfreaks.com/topic/127938-php-and-js-copy-to-clipboard/#findComment-662606 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.