简体   繁体   English

如何在新标签页中加载动态网页内容

[英]How to load a dynamic webpage content in a new tab

I'm working on a Backbone JS application in which I've got to load some dynamic data in a new tab, which is currently loading in the same page. 我正在开发Backbone JS应用程序,其中必须在新选项卡中加载一些动态数据,该选项卡当前正在同一页面中加载。 The existing thing with backbone is to use app.navigate() method #same page. 具有主干的现有内容是使用app.navigate()方法#same页面。

I tried using window.open(), and wrote a method onload() of it like this. 我尝试使用window.open(),并像这样编写了它的方法onload()。

var newWindow = window.open(openUrl+"#catalog2/"+genTimestamp(), '_blank');

newWindow.onload = function() {
app.navigate("/catalog2/"+genTimestamp(), false); 
};

But the script is loading / applying on the parent window, instead of the newly opened window, as a result of which, the new page is not loading properly. 但是脚本是在父窗口上加载/应用,而不是在新打开的窗口上加载,因此,新页面无法正确加载。 Any help will be appreciated. 任何帮助将不胜感激。

Backbone works very well for single page application. 骨干网非常适合单页应用程序。

Once you open a new window it's, by definition, no longer a single page application, and your routes or history object will not be applicable to the other window, since each window has its own history. 一旦打开新窗口,根据定义,它不再是单个页面应用程序,并且您的路线或历史记录对象将不适用于另一个窗口,因为每个窗口都有其自己的历史记录。

instead you could use good old newWindow.location.assign(url) 相反,您可以使用旧的newWindow.location.assign(url)

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

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