cyb Posted November 6, 2007 at 08:30 AM Report Share #145549 Posted November 6, 2007 at 08:30 AM Boas tenho aqui um problema que pensei ser simples mas ainda não consegui resolver, que é o seguinte dar função a um botão de copiar um texto da textarea para a área de trabalho, no ie funciona mas no firefox não, e ainda não consegui perceber porque é que não funciona deixo aqui o códigos que tenho em que ambos funcionam no ie mas no firefox não <html><head> <title>Test</title> <script type="text/javascript"> bBool=false var copiedtext="" var tempstore="" function initiatecopy() { bBool=true; } function copyit() { if (bBool) { tempstore=copiedtext document.execCommand("Copy") copiedtext=window.clipboardData.getData("textarea"); if (tempstore!=copiedtext) { alert(copiedtext); } bBool=false; } } document.onselectionchange = initiatecopy document.onmouseup = copyit </SCRIPT> </head> <BODY> <FORM name="frm"> <table border="1" align="center" bgcolor="#00CCFF"> <tr> <td colspan="2"><INPUT type="button" onClick="gen.select();gen.focus()" value="Selecionar"> <INPUT type="button" onClick="gen.initiatecopy();gen.copyit()" value="Copiar"> <INPUT type="button" onClick="gen.delete()" value="Apagar Tudo"></td></tr><tr> <td colspan="2"><textarea name="textarea" cols="62" rows="10" id="gen">Aqui está o conteúdo</textarea></td> </tr></table></FORM> </BODY> </html> <html><head> <title>Test</title> <script type="text/javascript">function copyToClipboard(s) { if( window.clipboardData && clipboardData.setData ) { clipboardData.setData("gen", s); } else { // You have to sign the code to enable this or allow the action in about:config by changing user_pref("signed.applets.codebase_principal_support", true); netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); var clip Components.classes['@mozilla.org/widget/clipboard;[[[[1]]]]'].createInstance(Components.interfaces.nsIClipboard); if (!clip) return; // create a transferable var trans = Components.classes['@mozilla.org/widget/transferable;[[[[1]]]]'].createInstance(Components.interfaces.nsITransferable); if (!trans) return; // specify the data we wish to handle. Plaintext in this case. trans.addDataFlavor('text/unicode'); // To get the data from the transferable we need two new objects var str = new Object(); var len = new Object(); var str = Components.classes["@mozilla.org/supports-string;[[[[1]]]]"].createInstance(Components.interfaces.nsISupportsString); var copytext=meintext; str.data=copytext; trans.setTransferData("text/unicode",str,copytext.length*[[[[2]]]]); var clipid=Components.interfaces.nsIClipboard; if (!clip) return false; clip.setData(trans,null,clipid.kGlobalClipboard); } }</SCRIPT> </head> <BODY> <FORM name="frm"> <table border="1" align="center" bgcolor="#00CCFF"> <tr> <td colspan="2"><INPUT type="button" onClick="gen.select();gen.focus()" value="Selecionar"> <INPUT type="button" onClick='copyToClipboard(document.getElementById("textarea").value);' value="Copiar"> <INPUT type="button" onClick="gen.delete()" value="Apagar Tudo"></td></tr><tr> <td colspan="2"><textarea name="textarea" cols="62" rows="10" id="gen">Aqui está o conteúdo</textarea></td> </tr></table></FORM> </BODY> </html> e tb tentei fazer uma opção que me elimina-se o conteúdo da textarea pensei que basta-se onClick="gen.delete()" mas devo estar enganado porque não funciona nem no ie nem no firefox. Fico aguardar sugestões para a resolução deste meu problema. cumps, cyb Link to comment Share on other sites More sharing options...
djthyrax Posted November 7, 2007 at 01:37 AM Report Share #145815 Posted November 7, 2007 at 01:37 AM document.execCommand("Copy") copiedtext=window.clipboardData.getData("textarea"); Isto são funções que só funcionam no IE, é impossível fazer isto no Firefox. Não peças ajuda por PM! A tua dúvida vai ter menos atenção do que se for postada na secção correcta do fórum! Link to comment Share on other sites More sharing options...
cyb Posted November 7, 2007 at 11:38 PM Author Report Share #146038 Posted November 7, 2007 at 11:38 PM document.execCommand("Copy") copiedtext=window.clipboardData.getData("textarea"); Isto são funções que só funcionam no IE, é impossível fazer isto no Firefox. pois não sabia disso, obrigado djthyrax. e não existe maneira de eu com outra coisa fazer a função que eu quero que funcione para o firefox???!! é que na net só encontrei os dois códigos acima que apresentei para a função que pretendo (copiar para a área de trabalho). Link to comment Share on other sites More sharing options...
djthyrax Posted November 8, 2007 at 12:25 AM Report Share #146051 Posted November 8, 2007 at 12:25 AM Não, o utilizador vai sempre ter de copiar o texto. Não peças ajuda por PM! A tua dúvida vai ter menos atenção do que se for postada na secção correcta do fórum! Link to comment Share on other sites More sharing options...
NCS_One Posted November 8, 2007 at 02:30 PM Report Share #146099 Posted November 8, 2007 at 02:30 PM Ois Se tiveres mesmo de fazer isso aqui ta : http://www.jeffothy.com/weblog/clipboard-copy/ Usa o flash para fazer o copy. Acho k nao funciona no Opera, mas fazes da maneira k tens para o IE e Opera, e usas este para o FF. Se a vida te voltar as costas aproveita e apalpa-lhe o cu. Link to comment Share on other sites More sharing options...
cyb Posted November 9, 2007 at 02:17 AM Author Report Share #146266 Posted November 9, 2007 at 02:17 AM Obrigado a todos, já consegui que isto funcione tanto para o ie e para o ff. se precisarem de o código, digam. Link to comment Share on other sites More sharing options...
GONCALOPES Posted July 7, 2008 at 11:44 PM Report Share #196395 Posted July 7, 2008 at 11:44 PM tens um problema no firefox, eu e precisamente ao contrario... firefox ok ie nada e por causa de uma galeria, nao sei o que fazer... codigo html <html> <head> <title>ACESA</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="css/site.css"> <style> p.MsoNormal {mso-style-parent:""; margin-top:0cm; margin-right:0cm; margin-bottom:10.0pt; margin-left:0cm; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif"; } .style2 { border-width: 0px; } --> </style> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <div> </div> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="text-align: justify"> <tr> <td align="center" valign="top"><table width="800" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td align="center" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td height="10" align="center" valign="top" bgcolor="#44444E"></td> </tr> <tr> <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="15" bgcolor="#44444E"> </td> <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="5"><img src="images/canto_esq.jpg" width="5" height="5" alt=""></td> <td></td> <td width="3"><img src="images/canto_dir.jpg" width="5" height="5" alt=""></td> </tr> <tr> <td> </td> <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="5"> </td> <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" valign="top"><table width="98%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="80"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <a href="http://www.itap-net.org"><img src="images/image001.jpg" width="670" height="65" alt="" align="middle" class="style2"></a></td> </tr> <tr> <td><span class="black-slogan-txt"></span></td> </tr> </table></td> <td align="right" valign="top"><table border="0" cellspacing="0" cellpadding="2"> </table></td> </tr> </table></td> </tr> <tr> <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/centro.jpg"> <tr> <td width="4"><img src="images/esquerda.jpg" width="4" height="35"></td> <td align="center" class="navigation_text"> <a href="index.html">Acesa</a></td> <td width="10"><img src="images/ligacao.jpg" width="10" height="35"></td> <td align="center" class="navigation_text"> <a href="noticias.html">Noticias</a></td> <td width="10"><img src="images/ligacao.jpg" width="10" height="35"></td> <td align="center" class="navigation_text"> <a href="eventos.html">Eventos</a></td> <td width="10"><img src="images/ligacao.jpg" width="10" height="35"></td> <td align="center" class="navigation_text"> <a href="Galeria.html"><u><strong>Galeria</strong></u></a></td> <td width="10"><img src="images/ligacao.jpg" width="10" height="35"></td> <td align="center" class="navigation_text"> <a href="Contactos.html">Contactos</a></td> </tr> </table></td> </tr> <tr> <td height="2"></td> </tr> <tr> <td height="8" bgcolor="#DB3C02"></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td height="10" align="center" valign="top"></td> </tr> <tr> <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="250" height="158"> <img src="images/logo_acesa_imgem.PNG" width="246" height="155" alt="" align="middle"></td> <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="10"> <tr> <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="22" valign="top"><span class="orange_bold_text">Galeria Acesa </span><span class="gray_bold_text"></span></td> </tr> <tr> <td height="10" align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="1" bgcolor="#999999"></td> </tr> </table></td> </tr> <tr> <td height="5" valign="top"><a href="Galeria.html" class="light_gray_link"><strong><u>Fotos Encontros Internacionais </u></strong></a></td> <tr> <td height="5" valign="top"><a href="eaitap.html" class="light_gray_link"><strong>Fotos EA ITAP </strong></a></td> </tr> <tr> <td height="5" valign="top" class="light_gray_link"><a href="torredeita.html" class="light_gray_link"><strong>Fotos Torredeita </strong></a></td> </tr> <tr> <td height="5" valign="top"> </td> </tr> <tr> <td height="5" valign="top"> </td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td height="5" align="center" valign="top"></td> </tr> <tr> <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="250" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" valign="top"><table width="93%" border="0" cellspacing="3" cellpadding="0"> <tr> <td height="25" valign="bottom"><div align="center"><span class="orange_bold_text">Links</span></div></td> </tr> <tr> <td height="1" bgcolor="#999999"></td> </tr> </table></td> </tr> <tr> <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="15" valign="top"></td> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="15"><div align="center"><span class="bold_sky_text">Europen</span></div></td> <td width="15" rowspan="5"> </td> </tr> <tr> <td height="3"></td> </tr> <tr> <td valign="top" class="light_gray_text">A Europen é uma grande loucura. Trata-se de uma mostra que integra uma 'instalação' artística e uma 'performance' com referências ao campo virtual.</td> </tr> <tr> <td height="3"></td> </tr> <tr> <td align="right"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="right"></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td height="25" align="center" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="15"></td> <td width="90%" height="1" bgcolor="#999999"></td> <td width="15"></td> </tr> </table></td> </tr> <tr> <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="15" valign="top"> </td> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td style="height: 15px"> <div align="center"><span class="bold_sky_text">Projecto Ergon</span></div></td> <td width="15" rowspan="5"> </td> </tr> <tr> <td height="3"></td> </tr> <tr> <td valign="top" class="light_gray_text">A plataforma Ergon é criada para permitir a professores, curriculum desenvolvedores e técnicos, que trabalham com a prática ou na empresa para aprender uns com os outros.</td> </tr> <tr> <td height="3"></td> </tr> <tr> <td align="right"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="right"> </td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td height="25" align="center" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="15"></td> <td width="90%" height="1" bgcolor="#999999"></td> <td width="15"></td> </tr> </table></td> </tr> <tr> <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="15" valign="top"> </td> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="15"><div align="center"><span class="bold_sky_text">Inform</span></div></td> <td width="15" rowspan="5"> </td> </tr> <tr> <td height="3"></td> </tr> <tr> <td valign="top" class="light_gray_text" style="height: 28px">Infor empresa espanhola, pretende continuar com a sua tarefa colectiva, de serviço e de contribuição no campo da formação profissional em todo o país de Espanha. </td> </tr> <tr> <td height="3"></td> </tr> <tr> <td align="right"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="right"> </td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td align="center" valign="top"> </td> </tr> </table></td> <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="10"> <tr> <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="22" valign="top" class="orange_bold_text">Feira Internacional </td> </tr> <tr> <td height="10" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="1" bgcolor="#999999"></td> </tr> </table></td> </tr> <tr> <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="5" valign="top"></td> </tr> <tr> <td valign="top" class="light_gray_text"><p> <style type="text/css"> /* CSS para a galeria */ .photopreview { width: 400px; margin: 0 auto; position: relative;} .photopreview li { float: left; width: 100px; height: 75px; padding: 10px;}.photopreview li img { position: relative; width: 100px; height: 75px; border: 1px outset #CCC; padding: 5px; background: #FFF;}.photopreview li:hover img { cursor: default; width: 160px; height: 120px; top: -37px; left: -50px; border: 1px outset #CCC; padding: 5px; z-index: 100; background: #EEE;}.photopreview li:active img, .photopreview:active li:hover img { width: 400px; height: 300px; position: absolute; left: 0; top: auto;} </style> </p> </td> <tr> <td valign="top" class="light_gray_text"><p> </p> <ul class="photopreview"> <li><a href="#"><img src="Galeria/09020008.JPG" alt="Acesa1" width="100" height="75"></a></li> <li><a href="#"><img src="Galeria/09020009.JPG" alt="Acesa 2" width="100" height="75"></a></li> <li><a href="#"><img src="Galeria/09020010.JPG" alt="Acesa 3" width="100" height="75"></a></li> <li><a href="#"><img src="Galeria/09020011.JPG" alt="Acesa 4" width="100" height="75"></a></li> <li><a href="#"><img src="Galeria/09020012.JPG" alt="Acesa 5" width="100" height="75"></a></li> <li><a href="#"><img src="Galeria/09020013.JPG" alt="Acesa 6" width="100" height="75"></a></li> <li><a href="#"><img src="Galeria/09020014.JPG" alt="Acesa 7" width="100" height="75"></a></li> <li><a href="#"><img src="Galeria/09020015.JPG" alt="Acesa 8" width="100" height="75"></a></li> <li><a href="#"><img src="Galeria/09020016.JPG" alt="Acesa 9" width="100" height="75"></a></li> </ul> </td> </tr> <tr> <td valign="top" class="light_gray_text"> </td> <tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td height="10" valign="top"><p> </p> </tr> <tr> <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="1" bgcolor="#999999"></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td height="10" align="center" valign="top"></td> </tr> </table></td> <td width="5"> </td> </tr> </table></td> <td> </td> </tr> <tr> <td><img src="images/canto_esq.jpg" width="5" height="5" alt=""></td> <td></td> <td width="5"><img src="images/canto_dir.jpg" width="5" height="5" alt=""></td> </tr> </table></td> <td width="15" bgcolor="#44444E"> </td> &nbs Link to comment Share on other sites More sharing options...
fnds Posted July 8, 2008 at 10:59 AM Report Share #196532 Posted July 8, 2008 at 10:59 AM GONCALOPES, Qual é o problema? É preciso esse código todo para te ajudar-mos a solucionar o problema? (E falta ai qualquer coisa, a tag html não está fechada) PS: Usa o geshi para formatar o código. Link to comment Share on other sites More sharing options...
dianaemanuel Posted February 3, 2015 at 04:37 PM Report Share #576501 Posted February 3, 2015 at 04:37 PM Obrigado a todos, já consegui que isto funcione tanto para o ie e para o ff. se precisarem de o código, digam. Boas tardes, Eu estou com o mesmo problema como é que o resolves-te? Link to comment Share on other sites More sharing options...
I-NOZex Posted February 7, 2015 at 10:57 PM Report Share #576765 Posted February 7, 2015 at 10:57 PM a unica forma sem ser o "ctrl+c" feito pelo user, é usando flash procura "js flash clipboard", vais encontrar o que precisas B2R » Beat2Revolution v3.0b | Regista e divulga-nos beat2revolution.net Link to comment Share on other sites More sharing options...
dianaemanuel Posted February 9, 2015 at 09:55 AM Report Share #576809 Posted February 9, 2015 at 09:55 AM Bons dias, Eu estou a tentar utilizar o ZeroClipboard mas está me a dar erro. O código que tenho é o seguinte: var clip = new ZeroClipboard(rowcopy, { moviePath: 'ZeroClipboard.swf' }); clip.setText(cliptext); clip.glue('copy'); Mas dá me erro quando é feito o clip.glue. Link to comment Share on other sites More sharing options...
I-NOZex Posted February 9, 2015 at 09:59 AM Report Share #576810 Posted February 9, 2015 at 09:59 AM porreiro era saber qual o erro... B2R » Beat2Revolution v3.0b | Regista e divulga-nos beat2revolution.net Link to comment Share on other sites More sharing options...
dianaemanuel Posted February 9, 2015 at 10:02 AM Report Share #576811 Posted February 9, 2015 at 10:02 AM clip.glue is undefined Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now