samedi 29 novembre 2014

Copying newlines in JavaScript alert to clipboard


Is this simply a browser issue or am I formatting content wrong?


I'm calling alert("This\nis\na\ntest"); and then pressing Ctrl + C to copy the contents of the alert message to my clipboard. This is working, except that the text copied to my clipboard doesn't contain the newlines. I've tried \r\n as well and although it prints the newlines in my alert box, they don't get copied to the clipboard in Chrome on Windows 8.


Is there a newline character I'm not using or is this a limitation I can't fix?


See this JSfiddle: http://jsfiddle.net/oscsy07b/1/


Thanks.





Aucun commentaire:

Enregistrer un commentaire