Home  >  Article  >  Web Front-end  >  Implementation code for using JS to operate IFRAME and its content in FRAME_javascript skills

Implementation code for using JS to operate IFRAME and its content in FRAME_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:02:29989browse

Question: I want to set the URL of an IFRAME in a FRAME on the page and the value of a TEXT in it by entering a piece of JS in the address bar, and then click the submit button. Note: The page belongs to another website. Do not give answers that change the page code. The specific situation is as follows:

Main page.htm:

view plaincopy to clipboardprint?



main.jsp:





Requirements:

1. After opening the main page, enter a piece of JS in the address bar to change the mainFrame The src is http://.../c.jsp.

2. After opening the main page, enter a piece of JS in the address bar to set the name of the mainFrame page to "txt1" The value of the text box is "119", and click the button with the name "btn1".

GOOGLE, but I really haven’t found any ready-made similar answers. So I tried it myself and found the answer. I believe it can be helpful to friends who ask the same question again.

1.javascript:frames("primaryFrame").document.mainFrame.location=http://.../c.jsp;

2.javascript:var a=frames( "primaryFrame").document.mainFrame.document.getElementById("txt1").value="119";frames("primaryFrame").document.mainFrame.document.getElementById("btn1").click();

As for setting the text box, why is it var a=frames("primaryFrame").document.mainFrame.document.getElementById("txt1").value="119"; instead of using frames("primaryFrame") directly. document.mainFrame.document.getElementById("txt1").value="119"; Everyone will know after trying it.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn