Ver Mensaje Individual
  #11 (permalink)  
Antiguo 08/10/2012, 15:08
Avatar de Reedyseth
Reedyseth
 
Fecha de Ingreso: enero-2009
Ubicación: Chihuahua, México
Mensajes: 419
Antigüedad: 16 años
Puntos: 36
Respuesta: Como pasar datos a una pagina contenida en un iframe

De todos modos para agregar mas a tu post te voy a poner como hacerlo con el iframe si es así que es lo que deseas hacer o si tu cabeza esta dando vueltas con jQuery, pero si te recomiendo que aprendas jQuery que te va a quitar muchos problemas de encima.

Bueno pasando a tu pregunta, supongamos que tenemos un html donde esta el input donde se va a hacer el post que luce como el siguiente:

toIframe.html:

Código HTML:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4.     <head>
  5.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6.         <title>SITE</title>
  7.         <style type="text/css" media="screen">
  8.             html, body {
  9.                 background-color: #000;
  10.             }
  11.         </style>
  12.     </head>
  13.     <body>
  14.         <h1>no text file</h1>
  15.        <form action="buscar.php" method="post" target="buscar">
  16.             <input type="text" name="contenido"/>
  17.         <input type="submit" name="setvideo" Value="buscar"/>
  18.        </form>
  19.        <br>
  20.         <iframe id="buscar" src="buscar.php"></iframe>
  21.     </body>
  22. </html>

y este es el código del iframe, buscar.php:
Código HTML:
Ver original
  1. <?php
  2.      if (isset($_POST['contenido'])){
  3.         echo$_POST['contenido'];
  4.     };
  5. ?>
  6. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  7. "http://www.w3.org/TR/html4/loose.dtd">
  8. <html xmlns="http://www.w3.org/1999/xhtml">
  9.     <head>
  10.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  11.         <title>SITE</title>
  12.        <style type="text/css" media="screen">
  13.             html, body {
  14.                 background-color: #fff;
  15.             }
  16.         </style>
  17.     </head>
  18.     <body>
  19.         <h1>Este es mi iframe</h1>
  20.        
  21.     </body>
  22. </html>

Con este código cuando te hagas el post se ira a tu iframe y se refrescará con la nueva información.

Puntos importantes a remarcar:
  • el post se hace a tu iframe en action="buscar.php"
  • para que tu información se vaya al iframe usamos el atributo target="buscar" donde buscar es el id de tu iframe.

espero que con eso sea respondida tu pregunta, ya que preguntaste como enviar la información a un iframe.