如何使用javascript刷新另一个页面而不在新选项卡中打开同一页面 [英] How to refresh another page using javascript without opening the same page in a new tab

查看:93
本文介绍了如何使用javascript刷新另一个页面而不在新选项卡中打开同一页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用Javascript或JQuery从其他页面刷新页面,而无需在新选项卡中打开同一页面。

Is it possible to refresh a page from another page using Javascript or JQuery without opening the same page in a new tab.

JS:

 var newtab = window.open('http://localhost:8081/app/home');
 newtab.document.location.reload(true);

我尝试了上述内容,但是在这里,它会打开一个新标签,页面相同,已经在浏览器中打开。

I tried the above, but here, it will open a new tab, with the same page, which is already opened in the browser.

请建议一种方法。

推荐答案

<我从之前的问题中得到了这个想法,这里他们使用了窗口对象引用重新加载弹出窗口,但对我来说它不起作用,因为,父窗口和子窗口运行在2个不同的端口。所以使用相同的技巧,我做的是:

I got the idea from a previous Question , here they used window Object Reference to reload the popup window, but for me it wont work, because, the parent window and child window runs in 2 different ports. So using the same trick, what i did is :

HTML:

<a onclick="openNewTab()">app2</a>

<a onclick="refreshExistingTab">Refresh</a>

JS:

<script>

    var childWindow = "";
    var newTabUrl="http://localhost:8081/app/home";

    function openNewTab(){
        childWindow = window.open(newTabUrl);
    }

    function refreshExistingTab(){
        childWindow.location.href=newTabUrl;
    }

</script>

这篇关于如何使用javascript刷新另一个页面而不在新选项卡中打开同一页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆