471,595 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 software developers and data experts.

Copy and Paste form in another frame

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
1 2120
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.

Similar topics

2 posts views Thread by Bob T Bunny | last post: by
2 posts views Thread by Greg | last post: by
6 posts views Thread by NuB | last post: by
7 posts views Thread by lgbjr | last post: by
9 posts views Thread by =?Utf-8?B?VGVycnk=?= | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.