[英]How To close the new window automatically when the redirect url API is hit
Hello i am using the react js and i am open a new window using this method.您好,我正在使用 react js,我正在使用此方法打开一个新窗口。
var newWindow = window.open(
this.state.url,
'myWindow',
"location=yes,width=600,height=600"
)
Using this method a new window is open and a redirection url is open and getting the response in new window i just want to close new window pop up after getting response.使用这种方法打开一个新窗口并打开一个重定向 url 并在新窗口中获取响应我只想在获得响应后关闭弹出的新窗口。 the redirection link is actually a api link in which i am sending the response.重定向链接实际上是一个 api 链接,我在其中发送响应。
Help me get out of this.帮我摆脱这个。 Thanks谢谢
你可以得到newwindow的事件loadstop然后关闭它。
I think this approach will solve your Issue.我认为这种方法将解决您的问题。 At leas if you open the new Window interaktiv.至少,如果您打开新的 Window interaktiv。 Automatically close browser/tab without opening it by javascript 自动关闭浏览器/选项卡而不用 javascript 打开它
Snippet from the other post which should be part of the response (dont know if possible in your case).来自另一篇文章的片段,它应该是响应的一部分(不知道您的情况是否可能)。
<script language="JavaScript" type="text/javascript">
function winClose() {
window.setTimeout("window.close();",2000)
}
</script>
You have newWindow
reference to your window pop up.你有newWindow
引用你的窗口弹出。 Now you can listen onload
method which gets fired once your window is fully loaded with content and dom
is generated.现在,您可以监听onload
方法,一旦您的窗口完全加载内容并生成dom
,就会触发该方法。 Refer here. 参考这里。 DO your stuff inside this funciton.在这个函数中做你的事情。
newWindow.onload = function() {
// do your stuff here
newWindow.close()
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.