Problem:
I am working on a project. There are two windows, one is the main window and the other is the window. open subwindow. now, after processing the corresponding event in the main window, call the corresponding function of the subwindow to pass some information and modify the content of the subwindow. Because it is done in the JavaScript code of the main window, it is found that after the subwindow function is called, the content of the subwindow has not changed, after alert () is added before the code of the subwindow function called by the Javascript in the main window, the content of the subwindow is changed correctly.
Possible situations:
In this case, a code after alert () can be used only when the page elements enter a certain State. After alert () is added, it is equivalent to a page element that has enough time to enter a certain State. If you are sure that your code is correct, you can put the code after alert () into a setTimeout function, that is to say, it should be okay to stop and run the following code.
Solution:
As mentioned above, my situation should be that the sub-window page elements have not been loaded, and the method to change the content of the sub-window page is called, resulting in no effect.
Put the corresponding code in setTimeout (), and the execution is delayed for one second. Everything is normal.