请教下大家一个关于chrome兼容性问题,我想要实现在关闭子页面时刷新父页面,现在的效果时点击“关闭”按钮,子页面未关闭,父页面刷新了,子页面仍置顶。主要代码:function closeEditInfo(){self.close();opener.location.reload();}
3条回答 默认 最新
关注让【道友老李】来帮你解答,本回答参考gpt编写,并整理提供,如果还有疑问可以点击头像关注私信或评论。
如果答案让您满意,请采纳、关注,非常感谢!
这个问题涉及到了页面之间的通信和刷新操作,可以尝试使用以下代码实现:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Parent Page</title> </head> <body> <button onclick="openChildPage()">Open Child Page</button> <script> function openChildPage() { var childPage = window.open('childPage.html', '_blank', 'width=600, height=400'); } function refreshParentPage() { location.reload(); } </script> </body> </html>在父页面中,点击按钮会打开一个子页面childPage.html:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Child Page</title> </head> <body> <button onclick="closeChildPage()">Close Child Page</button> <script> function closeChildPage() { opener.refreshParentPage(); window.close(); } </script> </body> </html>在子页面中,点击按钮会调用父页面的refreshParentPage函数来刷新父页面,并关闭子页面。 希望这能帮助到您解决问题。如果您有其他问题,请随时告诉我。
解决 无用评论 打赏 举报