Use JS to operate IFRAME in the FRAME and its implementation code

Source: Internet
Author: User

Q: I want to input a piece of JS in the address bar to set the IFRAME URL and TEXT value in a FRAME on the page, and then click Submit. Note: The page is from other websites. Do not give answers to some Page code changes. The details are as follows:

Main Page .htm:

View plaincopy to clipboardprint?
<FRAMESET border = 0 frameSpacing = 0 frameBorder = 0 cols = *, 1005, *> <FRAME src = "blank.html" frameBorder = 0 noResize scrolling = no> <FRAMESET border = 0 frameSpacing = 0 rows = *, 585, * frameBorder = 0> <FRAME name = Frame1 src = "http ://... /blank.html "frameBorder = 0 noResize scrolling = no> <FRAME name = primaryFrame src =" http ://... /main. jsp "frameBorder = 0 noResize scrolling = no> <FRAME src =" http ://... /blank.html "frameBorder = 0 noResize scrolling = no> </FRAMESET> <FRAME src =" http ://... /blank.html "frameBorder = 0 noResize scrolling = no> </FRAMESET>

<FRAMESET border = 0 frameSpacing = 0 frameBorder = 0 cols = *, 1005, *> <FRAME src = "blank.html" frameBorder = 0 noResize scrolling = no> <FRAMESET border = 0 frameSpacing = 0 rows = *, 585, * frameBorder = 0> <FRAME name = Frame1 src = "http ://... /blank.html "frameBorder = 0 noResize scrolling = no> <FRAME name = primaryFrame src =" http ://... /main. jsp "frameBorder = 0 noResize scrolling = no> <FRAME src =" http ://... /blank.html "frameBorder = 0 noResize scrolling = no> </FRAMESET> <FRAME src =" http ://... /blank.html "frameBorder = 0 noResize scrolling = no> </FRAMESET> main. jsp:

<Iframe id = chatFrame name = chatFrame src = "http: //.../a. jsp"> </iframe>

<Iframe id = mainFrame name = mainFrame src = "http: //.../B. jsp"> </iframe>

Requirements:

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

2. after the home page is opened, enter a piece of JS in the address bar to set mainFrame. In this case, the value of the text box "txt1" on the page is "119 ", click "btn1.

After GOOGLE, no similar answers were found. So I tried and got the answer. I believe it will be helpful for anyone who asks the same question.

1. javascript: frames ("primaryFrame" 2.16.doc ument. mainFrame. location = http: //.../c. jsp;

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

Why is the text box var a = frames ("primaryFrame" 2.16.document.mainframe.doc ument. getElementById ("txt1 "). value = "119"; instead of using frames ("primaryFrame" example .document.mainframe.doc ument. getElementById ("txt1 "). value = "119"; you can try it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.