简体   繁体   English

是否可以使用JavaScript从一个打开的页面跳转到另一个页面?

[英]Is it possible to use JavaScript to jump from one open page to another?

Sorry if this is naive question. 抱歉,这是一个幼稚的问题。

I heard in HTML5 there is inter page communication with JavaScript. 我听说在HTML5中存在与JavaScript的页面间通信。 I was wondering if it is possible to use JavaScript to let the focus jump from one page to another page it's having communication with? 我想知道是否可以使用JavaScript让焦点从与其通信的一页跳到另一页?

For example, if I have one page A send some data to the other page B so that page B is updated after receiving the data, can I have page B (or tab B) brought to the front (before all other windows/tabs in z-order), without having to let the user click page B? 例如,如果我有一个页面A向其他页面B发送一些数据,以便在接收到数据后更新页面B,我是否可以将页面B(或选项卡B)带到最前面(在所有其他窗口/选项卡之前) z顺序),而不必让用户点击页面B?

Thanks. 谢谢。

PS I don't want page B to reload and lose changes made by the user via changing the DOM. PS我不希望页面B重新加载并丢失用户通过更改DOM所做的更改。

Yes you can, use this code by using focus.. here is the complete code 是的,您可以,通过使用焦点使用此代码。这是完整的代码

var win=window.open("url");
win.focus();

You can also add parameters, here is the code 您还可以添加参数,这是代码

var win = window.open("url","name","width=700,height=700,top=200,left=300,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no");
win.focus();

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

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