30/03/2010, 23:24
|
| | Fecha de Ingreso: agosto-2005 Ubicación: Argentina, Capital Federal
Mensajes: 435
Antigüedad: 18 años, 8 meses Puntos: 2 | |
Respuesta: como capturo la variable en un iframe Cita:
Iniciado por estibaliz2006 vale....perfecto el debate....pero y mi problema???? Cita:
Iniciado por zaqpz Aunque esto es más bien un tema de JavaScript te he hecho un ejemplito para que lo adaptes a gusto. Código PHP: <?php if(!empty($_POST)) { echo 'Post generado: '.htmlentities($_POST['html']); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script type="text/javascript"> function carga() { vHtml=window.frames[0]; vHtml.document.designMode="on"; } function enviar() { document.getElementById("html").value=vHtml.document.body.innerHTML; return true; } function formato(tipo, argumento) { vHtml.document.execCommand(tipo, false, argumento); vHtml.focus(); } </script> </head> <body onload="carga();"> <form method="post"> <iframe width="700" height="300" id="editor"></iframe> <input type="hidden" name="html" id="html" /> <button type="button" onclick="formato('bold')"><b>B</b></button> <button type="submit" onclick="enviar();">Enviar</button> </form> </body> </html> Te agregué un botón para poner negritas así pruebas cómo se genera el código y cómo lo recibes.
Saludos.
PD: no uses PHP_SELF como action del form para que tu sitio no quede vulnerable a ataques XSS. |