javascript - Get textbox within a form of an iframe -


how can textbox in form , form in iframe javascript? simplified code is:

<!-- other code -->      <div id="login_panel_div">          <iframe id="popuploginscreen" src="login.jsp" name="popupcontent">              <html xmlns="http://www.w3.org/1999/xhtml">              <head>             </head>              <body>                  <form id="loginform" method="post" name="loginform">                     <h2>login account</h2>                                            <label>username:</label>                      <input id="username" type="text" name="j_username">                      <label>password:</label>                      <input id="password" type="password" name="j_password">                      <button id="submitloginbtn" value="login" name="submitloginbtn" type="submit">login</button>                 </form>              </body>              </html>          </iframe>      </div> <!-- other code --> 

if want input id "txtbox" should do?

thanks , regards.

as xiao 啸 pointed me, solution is:

var iframe = document.getelementbyid('popuploginscreen'); var innerdoc = iframe.contentdocument || iframe.contentwindow.document; var usernametextbox = innerdoc.getelementbyid('username'); usernametextbox.focus(); 

requesting thread close.

thanks.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -