2013-04-05 63 views
0

如何使用post函数将字段传递到IFrame?我正在使用目标标签,但似乎不起作用。应该发生的事情是,当我提交字段时,它将用户名和变量发布到论坛并登录。但是,我只是被重定向到登录页面。知道iframe与字段不在同一文件中可能会有帮助。向IFrame发布HTML值

 <form action="http://www.website.net/login.php" method="post" target="my_iframe"> 
     <label for="username">Username</label><input type="text" name="username" required> 
     <label for="password">Password</label><input type="password" name="password" required> 
     <input type="submit" name="login" value="Login" class="loginbtn"/><a href="http://www.website.net/register.php">Register</a> 
     </form> 

    <iframe name="my_iframe" src="http://www.website.net/forums/ucp.php?mode=login" frameborder="0" scrolling="auto" width="100%" height=1500px marginwidth="0" marginheight="5" ></iframe> 
+0

可能重复[你如何发布到iframe?](http://stackoverflow.com/questions/168455/how-do-you-post-to-an-iframe) – Class 2013-04-05 02:19:35

+0

是的,我已经看到后,我已经按照它的指示,但它仍然无法正常工作。 – 2013-04-05 02:53:23

回答

1

试一下:

<form action="http://www.website.net/login.php" method="post" target="my_iframe"> 
     <label for="username">Username</label><input type="text" name="username" required> 
     <label for="password">Password</label><input type="password" name="password" required> 
     <input type="submit" name="login" value="Login" class="loginbtn"/><a href="http://www.website.net/register.php">Register</a> 
     </form> 

    <iframe name="my_iframe" src="http://www.website.net/forums/ucp.php?mode=login" frameborder="0" scrolling="auto" style="width:100%;height:1500px;margin: 5px 0;"></iframe> 

你忘了插入 “” 在高度iframe的属性。

请记住,始终使用CSS和HTML属性,根据W3C HTML5/XHTML 1.0规则,它们已被弃用。

+0

感谢您的回复。我删除了iframe,并改变了论坛标题,而且一切正常。 – 2013-04-06 00:00:01