如何使用Javascript刷新另一个选项卡 [英] How can I refresh a tab from another using Javascript
问题描述
我希望在创建新帖子时能够实现Wordpress的功能。它允许您通过打开新选项卡来预览帖子。如果在此之后编辑帖子并再次预览,而不是打开另一个标签,则会刷新之前打开的标签(前提是它仍处于打开状态)。
I'm looking to achieve something like Wordpress does when you create a new post. It allows you to preview your post by opening a new tab. If, after that, you edit the post and preview it again, rather than opening another tab, it refreshes the previously opened tab (provided it is still open).
来自一些研究似乎我可以打开一个新窗口并给它一个名称来识别它,如下所示:
From some research it seems I can open a new window and give it a name to identify it, like this:
window.open(url, foobar);
但是,我怎样才能稍后刷新此标签? location.reload()
似乎没有将名称作为参数。
But, how can I later refresh this tab? location.reload()
does not seem to take a name as an argument.
推荐答案
如果我没记错的话,可以这样做:
If I remember correctly this is the way to do it:
var win = window.open(url, "foobar");
win.location.reload();
这篇关于如何使用Javascript刷新另一个选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!