dtny30176
2013-04-05 02:12
浏览 16
已采纳

将HTML值发布到IFrame

How would I use the post function to pass fields onto an IFrame? I am using the target label but it doesn't seem to work. What is supposed to happen is when I submit the fields, it posts the username and variable to a forum and logs me in. However, I am only being redirected to the login page instead. It might be helpful to know that the iframe is in a different file than the field.

     <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>
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dqce48404 2013-04-05 03:18
    已采纳

    Try that:

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

    You forgot to insert "" in the height iframe's property.

    Remember to always use CSS then HTML proprerties, they are deprecated as per W3C HTML5/XHTML 1.0 rules.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题