I want to copy a string to the clipboard.
The string must have some newlines (CRLF).
When I run the page I get an error.
This is the code:
<SCRIPT LANGUAGE='JavaScript'>
function CopyToClipboard()
{
var Data;
Data = 'This is the first line.' + '\n' + 'This is the second line.';
window.clipboardData.setData('TEXT', Data);
}
</SCRIPT>
The source of the html page is:
<SCRIPT LANGUAGE='JavaScript'>
function CopyToClipboard()
{
var Data;
Data = 'This is the first line.' + '
' + 'This is the second line.';
window.clipboardData.setData('TEXT', Data);
}
</SCRIPT>
So the '\n' is translated into a newline and the javascript does not work.
What can I do so that the javascript works and the text to copy to the clipboard can have some newlines?
Thanks.
The string must have some newlines (CRLF).
When I run the page I get an error.
This is the code:
<SCRIPT LANGUAGE='JavaScript'>
function CopyToClipboard()
{
var Data;
Data = 'This is the first line.' + '\n' + 'This is the second line.';
window.clipboardData.setData('TEXT', Data);
}
</SCRIPT>
The source of the html page is:
<SCRIPT LANGUAGE='JavaScript'>
function CopyToClipboard()
{
var Data;
Data = 'This is the first line.' + '
' + 'This is the second line.';
window.clipboardData.setData('TEXT', Data);
}
</SCRIPT>
So the '\n' is translated into a newline and the javascript does not work.
What can I do so that the javascript works and the text to copy to the clipboard can have some newlines?
Thanks.