Connecting Tech Pros Worldwide Forums | Help | Site Map

Copy to ClipBoard problem

Jean-Luc ERNST
Guest
 
Posts: n/a
#1: Jul 23 '05
Hello,
I apologize for my english, I'm french speaking...

Could someone help me to finalize a little project? I'm writing a form
for my site but I'don't know many in Javascript (I'm a newbee).

When the form is completed, the visitor may display it in another window
for verification, printing or sending by e-mail. When he opens the
second window, the form's content is send automatically to the clipboard
so it could be pasted in another application (Word, etc.).

I demonstrate it in two simple pages.

The first file:
http://cjoint.com/?eynDdWz1d8
is a page showing how it works. When the page is opened, a text
("test10") is pasted in the clipboard. You may verify and paste it in
another application.

The second file is the final projet (simplified for demonstration
purpose):
http://cjoint.com/?eynERRFvDd
I have transferred the working code in this project but the "copy to
clipboard" part doesn't function. If anybody fluent in Javascript could
tell me what is wrong, I would be helped!

--

Cordialement,
Jean-Luc ERNST



McKirahan
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Copy to ClipBoard problem


"Jean-Luc ERNST" <jeanlucpointernst@advalvaspointbe> wrote in message
news:23dd9$426b83b5$52aea660$14401@news.versatel.n l...[color=blue]
> Hello,
> I apologize for my english, I'm french speaking...
>
> Could someone help me to finalize a little project? I'm writing a form
> for my site but I'don't know many in Javascript (I'm a newbee).
>
> When the form is completed, the visitor may display it in another window
> for verification, printing or sending by e-mail. When he opens the
> second window, the form's content is send automatically to the clipboard
> so it could be pasted in another application (Word, etc.).
>
> I demonstrate it in two simple pages.
>
> The first file:
> http://cjoint.com/?eynDdWz1d8
> is a page showing how it works. When the page is opened, a text
> ("test10") is pasted in the clipboard. You may verify and paste it in
> another application.
>
> The second file is the final projet (simplified for demonstration
> purpose):
> http://cjoint.com/?eynERRFvDd
> I have transferred the working code in this project but the "copy to
> clipboard" part doesn't function. If anybody fluent in Javascript could
> tell me what is wrong, I would be helped!
>
> --
>
> Cordialement,
> Jean-Luc ERNST[/color]

Your function needs to be in the new document.

pop = window.open();
pop.document.write("<html><body bgcolor='#FF9999'
onLoad='document.contenu.valeur.createTextRange(). execCommand('Copy')'><cent
er>");
pop.document.write("<form action='' method='post' name='contenu'><input
type='hidden' name='valeur' value='<p>NAME: " + name + "<p>E-MAIL: " + mail
+ "'></form>");



Jean-Luc ERNST
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Copy to ClipBoard problem


"McKirahan" <News@McKirahan.com> a écrit dans le message de news:
6IadnTFD875invHfRVn-ug@comcast.com...
....snip...[color=blue]
> Your function needs to be in the new document.[/color]
....snip...

Thank you McKirahan,
Do you have tested your suggestion ?
I made the changes you suggested but it doesn't work.
Perhaps something I have forgotten ?

Here my corrected file:
http://cjoint.com/?ezqjgvuCQC
(right-click on the file's name on the page's top and open it in a new
window: the source code will be clean).

Cordialement,
Jean-Luc Ernst


McKirahan
Guest
 
Posts: n/a
#4: Jul 23 '05

re: Copy to ClipBoard problem


"Jean-Luc ERNST" <jeanlucpointernst@advalvaspointbe> wrote in message
news:9bec3$426cfa05$52aea9dc$14119@news.versatel.n l...[color=blue]
> "McKirahan" <News@McKirahan.com> a écrit dans le message de news:
> 6IadnTFD875invHfRVn-ug@comcast.com...
> ...snip...[color=green]
> > Your function needs to be in the new document.[/color]
> ...snip...
>
> Thank you McKirahan,
> Do you have tested your suggestion ?
> I made the changes you suggested but it doesn't work.
> Perhaps something I have forgotten ?
>
> Here my corrected file:
> http://cjoint.com/?ezqjgvuCQC
> (right-click on the file's name on the page's top and open it in a new
> window: the source code will be clean).
>
> Cordialement,
> Jean-Luc Ernst
>
>[/color]

I did not test it; when I did I saw that it won't work.

However, the following does; adapt it for your needs.

<html>
<head>
<title>pop.htm</title>
</head>
<body>
<script type="text/javascript">
var name = "x";
var mail = "y";
var pop = window.open();
pop.document.write("<html>\n");
pop.document.write("<body bgcolor='#FF9999' onLoad='clip()'>\n");
pop.document.write("<form action='' method='post' name='contenu'>\n");
pop.document.write("<input type='hidden' name='valeur' value='<p>NAME:
" + name + "<p>E-MAIL: " + mail + "'>\n");
pop.document.write("</form>\n");
pop.document.write("<" + "script type='text/javascript'>\n");

pop.document.write("document.contenu.valeur.create TextRange().execCommand('C
opy');\n");
pop.document.write("alert('Paste from the clipboard!');\n");
pop.document.write("</" + "script>\n");
pop.document.write("</body>\n");
pop.document.write("</html>\n");
</script>
</body>
</html>


Closed Thread


Similar JavaScript / Ajax / DHTML bytes