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.