简体   繁体   English

window.open不会每次都打开一个新窗口

[英]window.open doesn't open a fresh window every time

When I run window.open, it opens up and whatever the contents were before appear while it loads the new contents. 当我运行window.open时,它将打开,并且在加载新内容时会显示之前的内容。 So in my system, you can click purchase item, and it directs you to a payment provider, and then when you're done (or any time during the process) you close the window via the X in the corner. 因此,在我的系统中,您可以单击购买项目,它会将您定向到付款提供商,然后在完成操作后(或过程中的任何时间),通过角落的X关闭窗口。

When you go to pay for another item, the window opens again and it remembers the previous contents, while it loads. 当您支付其他项目的费用时,该窗口会再次打开,并且在加载时会记住先前的内容。 This is ugly and confusing for people that are seeing details briefly about the previous order. 对于只是短暂地了解有关先前订单的详细信息的人员而言,这是丑陋且令人困惑的。

Any idea how to wipe the contents or stop it remembering? 知道如何擦除内容或停止记忆吗?

window.open(d.url, 'mywindow', '');

I tried clearing with: 我尝试使用以下方法进行清除:

mywindow.document.getElementsByTagName('body')[0].innerHTML = '';

but it says mywindow does not exist. 但是它说mywindow不存在。 Also I don't know if this would interrupt the loading of the actual url. 我也不知道这是否会中断实际网址的加载。

Any ideas? 有任何想法吗?

Edit: I should add, it opens a page on the same domain and then that page redirects to the 3rd party. 编辑:我应该添加,它将在同一域上打开一个页面,然后该页面重定向到第三方。

您需要给窗口重新命名。

window.open(d.url, 'newNameOnEveryWindowOpen', '');

Every time you should be given new window name. 每次应该给您新的窗口名称。

window.open(d.url, 'mywindow' + Math.random(), '');

Like: 喜欢:

window.open("https://www.google.co.in/", 'mywindow2' + Math.random())

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

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