2013-06-18 25 views
0

我在iframe中有一個登錄表單。下面是主要頁面的代碼:在Iframe中未登錄的登錄表單

<!DOCTYPE html> 
<html> 
    <head> 
     <meta content="text/html; charset=windows-1252" http-equiv="content-type"> 
     <script language="javascript"> 
      function SubmitForm() { 
       document.getElementById('loginframe').contentWindow.document.getElementById('login').submit(); 
      } 
     </script> 
     <title>Login to Vote</title> 
    </head> 
    <body> 
     <iframe id="loginframe" src="sasloginhandler.html"></iframe> 
     <input onclick="SubmitForm()" value="Submit form" type="button"> 
    </body> 
</html> 

這裏是針對「sasloginhandler.html」頁面的代碼:

<!DOCTYPE html> 
<html> 
    <head> 
    <meta content="text/html; charset=windows-1252" http-equiv="content-type"> 
    <title>Login to Vote</title> 
    </head> 
    <body> 
    <form action="https://moodle.standrews-de.org/login/index.php" method="post" 
     id="login"> 
     <div class="loginform"> 
     <div class="form-input"> <input name="username" placeholder="Username" 
      id="username" 
      size="15" 
      type="text"> 
     </div> 
     <div class="form-input"> <input name="password" placeholder="Password" 
      id="password" 
      size="15" 
      value="" 
      type="password"> 
      <input id="loginbtn" value="Login" type="submit"> </div> 
     </div> 
     <div class="forgetpass"><a href="forgot_password.php">Forgotten your 
      username or password?</a></div> 
    </form> 
    </body> 
</html> 

的問題是,無論是IFRAME也不是裏面的提交按鈕iframe外部的javascript提交按鈕可以做任何事情。我已經測試了自己的iframe代碼,它工作正常,所以它似乎是導致問題的iframe的一部分。但是,我不知道爲什麼會這樣。

謝謝!

+0

iframe的代碼在自己的車廂跑到得到它,我想,這樣你就無法通過添加按鈕對其產生影響在iframe之外。 – Paul

+0

也許,但即使iframe中的登錄按鈕也不起作用......好像iframe阻止重新加載。 –

回答

0

在iframe形式的ID login但你嘗試用loginform

document.getElementById('loginframe').contentWindow.document.getElementById('login').submit(); 
+0

謝謝,那是一個愚蠢的錯誤。但是,它仍然不起作用。 –