Copy to ClipBoard problem

J

Jean-Luc ERNST

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!
 
M

McKirahan

Jean-Luc ERNST said:
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!

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>");
 
J

Jean-Luc ERNST

"McKirahan" <[email protected]> a écrit dans le message de (e-mail address removed)...
....snip...
Your function needs to be in the new document.
....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
 
M

McKirahan

Jean-Luc ERNST said:
"McKirahan" <[email protected]> a écrit dans le message de (e-mail address removed)...
...snip...
...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

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.createTextRange().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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top