简体   繁体   English

在父窗口上刷新子窗口

[英]Refresh child window on parent window

how can i refresh child page if parent window reloads? 如果父窗口重新加载,如何刷新子页面?

Suppose A.html has a link that opens B.html . 假设A.html具有打开B.html的链接。 B.html will automatically refresh if A.html reloads. 如果A.html重载B.html会自动刷新。

Any javascript/jQuery way? 任何JavaScript / jQuery方式?

You can control the child if you open it like this: (in A.html ) 如果像这样打开子项,则可以对其进行控制:(在A.html中

baby = window.open('B.html');

Refreshing the child will then be done like this: 然后刷新孩子,如下所示:

baby.history.go(0);

If you refresh A, the pages unload -event will be invoked. 如果刷新A,则将调用页面unload -event。 So to refresh B when one refreshes (or leaves or closes, for that matter) A, you can do: (in A.html ) 因此,当一个人刷新(或为此离开或关闭)A时刷新B,您可以执行以下操作:(在A.html中

<body onunload="baby.history.go(0);">

But, after the refresh all javascript variables will be lost! 但是,刷新后,所有的javascript变量都将丢失! It will lose its connection with page B! 它将失去与页面B的连接! So it will only work for one time. 因此,它将只工作一次。

I think a solution will be to make a refresh button/link in A.html , that will refresh the data on the page (A) dynamically in order to maintain the connection to the child windows (B). 我认为一种解决方案是在A.html中创建一个刷新按钮/链接,该按钮/链接将动态刷新页面(A)上的数据,以保持与子窗口(B)的连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM