i have little script like echo '<script type="text/javascript">var url="'.$url.$name.'"; alert(url)</script>'; PHP: now i want this variable direct copy to window clipboard with out click any button .because i already searched many tutorial that come with click ....but i want simple variable to window clipboard. simple solution : http://lab.artlung.com/copy-to-clipboard-javascript/ <script language="javascript" type="text/javascript"> // Microsoft Internet Explorer only // Manipulating the system clipboard in JavaScript // Read more at: // http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/clipboarddata.asp // set the clipboard var x = 'Whatever you want on the clipboard'; window.clipboardData.setData('Text',x); // get the clipboard data window.clipboardData.getData('Text'); // clear the clipboard // window.clipboardData.clearData(); </script> Thanks for reading this ..problem solved
beware that this will only work on Microsoft browsers (Internet explorer) and not in other browsers (firefox, safari, chrome) or any other OS (iphone, mac, linux). For security reasons webpages are not allowed to see or alter what's on a user's clipboard. Imagine that I made a website that obtained the text on your clipboard and sent it to my webserver. Or that you've copied some important data on your clipboard and a webpage erases it.
that does not work with the latest flash / firefox. try this instead: http://code.google.com/p/zeroclipboard/