parent window iframe element trigger click by simple JavaScript -


In the iframe element of the parent window it is necessary to trigger the occurrence of simple javascript clicking.

Original Window

  & lt; Html & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-language" content = "n" /> & Lt; Title & gt; Main window & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Iframe scrolling = "auto" src = "html_test.php" & gt; & Lt; / Iframe & gt; & Lt; Button onclick = 'window.open ("child.html") & gt; Open window & lt; / Button & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

hair window

  & lt; Script type = "text / javascript" & gt; . Click on window.opener.document.getElementsByTagName ('iframe') [0] .document.getElementById ('main_tab') (); & Lt; / Script & gt;   

But onload child window gets this JavaScript error:

  type error: window.opener.document.getElementsByTagName ('iframe') [0] .document is undefined   

and file html_test.php div element main_tab is there already.

html_test.php is html:

  & lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Exam iframe & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Ul & gt; & Lt; Li id = "main_tab" onclick = "alert ('test click')" & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Body & gt; & Lt; / Html & gt;    

If your opener window is ifream page, just do this code .

  click on window.opener.document.getElementById ('main_tab') ();    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -