R
Risto Heinonen
Hi.
I have a web page that has images and text. I can carefully select one
image and the on the right of the image and then copy & paste to Word.
Is it possible to make javascript do the same: select the same area
(divided by <div> tag) and copy to clipboard?
So far I succeeded to make the script to copy the area inside <div> but
it was plain html-text.
The idea is to have tha data in clipboard so one can paste it to Word
remaining the layout like it is in html-file.
Here's what I have now in my html-file:
....
<script>
function copyToClipboard()
{
var x=document.getElementById('copythis');
document.form.copyArea.value=x.innerHTML;
y = document.form.copyArea.createTextRange();
y.select();
y.execCommand("Copy");
}
</script>
....
<div id="copythis">
.... image and text in html-table to be copied to clipboard ...
</div>
....
<form name="form">
<input type="button" name="copy" value="Copy to clipboard"
onClick="copyToClipboard()">
<input type="hidden" name="copyArea" value>
</form>
....
Any help is appreciated.
- Risto
I have a web page that has images and text. I can carefully select one
image and the on the right of the image and then copy & paste to Word.
Is it possible to make javascript do the same: select the same area
(divided by <div> tag) and copy to clipboard?
So far I succeeded to make the script to copy the area inside <div> but
it was plain html-text.
The idea is to have tha data in clipboard so one can paste it to Word
remaining the layout like it is in html-file.
Here's what I have now in my html-file:
....
<script>
function copyToClipboard()
{
var x=document.getElementById('copythis');
document.form.copyArea.value=x.innerHTML;
y = document.form.copyArea.createTextRange();
y.select();
y.execCommand("Copy");
}
</script>
....
<div id="copythis">
.... image and text in html-table to be copied to clipboard ...
</div>
....
<form name="form">
<input type="button" name="copy" value="Copy to clipboard"
onClick="copyToClipboard()">
<input type="hidden" name="copyArea" value>
</form>
....
Any help is appreciated.
- Risto