简体   繁体   中英

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. The existing thing with backbone is to use app.navigate() method #same page.

I tried using window.open(), and wrote a method onload() of it like this.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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