By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,566 Members | 1,779 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,566 IT Pros & Developers. It's quick & easy.

Copy and Paste form in another frame

P: n/a
Hi all,

I am trying to copy a form that is in one frame, using a button on another
frame. The form has a couple of tables inside it. I can get it working
when the button is in the same frame, but not in different ones. I get an
"invalid argument" error on the controlRange.addElement(x) line.

What I have so far is:

<script language='javascript'>
function CopyForm() {
if (document.body.createControlRange) {
var x = window.parent.fraRight.document.getElementById('Fo rm1');
x.contentEditable = 'true';
var controlRange;
controlRange = document.body.createControlRange();
controlRange.addElement(x);
controlRange.execCommand("Copy");
x.contentEditable = 'false';
alert('The table is now copied to memory. \nStart Excel, and Paste
the table into a new worksheet.');
}
</Script>

where fraRight is the name of the frame the form is in, and Form1 is the
name of the form I want to copy. The only thing I have changed from when it
was working in the one frame, is:
var x = window.parent.fraRight.document.getElementById('Fo rm1');
used to be
var x = document.getElementById('Form1');

I can do things like alert(x.name) and get the right name of the form, so I
think I have got the object properly. Is there any other way to make sure?

Any help appreciated.

Thanks,

Bob T


Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <41********@clear.net.nz>, bo*********@yahoo.com says...

I can do things like alert(x.name) and get the right name of the form, so I
think I have got the object properly. Is there any other way to make sure?

Any help appreciated.


What you seem to be trying to do is an IE-only feature - copying
"Form1" to the clipboard, then pasting it into another application.
Consider using a different method to select the things to copy, then
let the user Ctrl+C or click on "copy" to make your code compatible
with other browsers.

At the very least, do feature detection and warn users if
"execCommand" isn't supported by their choice of user agent.

Cheers, Rob.
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.