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 Quote Link to comment 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; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.