Home >Web Front-end >HTML Tutorial >Please teach the parent window how to control the child window_html/css_WEB-ITnose
I open b.html in a.html. After opening it, I want to modify some content in b. For example, there is a text box in b. I want to modify it in a. What should I do? ?
I tried this, but it didn’t work:
In a:
function openhtml(){
var childwin = window.open("b.html");
childwin. document.getElementById("textbox").value="abcde";
}
bpage
I don’t know how to study. A hero is coming
var obj = parent.frames[" frameName"].window;
Get the object of the sub-window
obj.document.getElementById('clientID')
Get the document node of the object of the sub-window
Please try again~ ~See
cannot be implemented. You can only pass the address bar (or cookie) parameters and let the b page handle it according to the parameters.
Alternative implementation:
Method 1:
a page In the click event, write a Session (or static variable, the same thing) to the server
In page b, use a timer to regularly query the server for the Session (or static variable). If there is a change, modify the page according to the value
This method can achieve the function you mentioned, with a certain delay;
Method 2:
Similar to 1, but the value is written in the client cookie, and the b page queries the cookie regularly, and there is a certain delay. , but it would be much better if there is no communication process
This function is not recommended because you should not have such a need for web programs. For the reason, please learn more about the page process, which is the running process of web programs:
Request--Response;
cannot be implemented. You can only pass the address bar (or cookie) parameters and let the b page handle it according to the parameters.
Alternative implementation:
Method 1:
Write a Session (or static variable, the same thing) to the server in the click event of page a
Use a timer in page b to regularly query the session (or static variable) on the server and find out If there is a change, modify the page according to the value
This method can achieve the function you mentioned, with a certain delay;
Method 2:
Similar to 1, but writes the value in the client cookie , there is a certain delay in the regular cookie query on the b page, but it will be much better if there is no communication process
This function is not recommended because you should not have such a need for web programs. Please understand the page process in detail. , which is the running process of a web program:
request-response;