r/javascript • u/Leather_Advice_405 • Mar 23 '23
Removed: r/LearnJavascript When using window.open(url,popup) how to get a spinner until the url loads and wanted to show popup if url loads successfully with status 200 and show error modal on failure of this url.
/r/JavaScriptTips/comments/11ypn8q/when_using_windowopenurlpopup_how_to_get_a/[removed] — view removed post
4
u/absorbantobserver Mar 23 '23
Do you control the site of the pop-up?
1
u/Leather_Advice_405 Mar 23 '23
Nope It’s a different origin, the url changes to another origin. So how to get status code of it
3
u/absorbantobserver Mar 23 '23
You pretty much don't. There's no way around the browser security in that case.
1
u/KaiAusBerlin Mar 23 '23
Well it is. But you would need a backend for that making the http requests for you and redirecting the response to your browser. In that way you wouldn't wait for the original request but the redirected one. Same origin, no problem.
1
u/absorbantobserver Mar 23 '23
I like that solution but that still wouldn't help you determine that the final page actually loaded, just that the popup actually opened.
1
u/KaiAusBerlin Mar 23 '23
Sure, but your backend could support that by the http request status and only send the response on a 2XX status code. That way you could ensure that the requested page was fully loaded.
1
u/joombar Mar 23 '23
Request the url and do an if/then based on the status code? Needs more context.
1
u/shuckster Mar 23 '23 edited Mar 23 '23
Is it possible to check a status-code from readystatechange or onload for a popup?
Not sure, but I had a go at the problem.
1
•
u/javascript-ModTeam Mar 23 '23
Hi u/Leather_Advice_405, this post was removed.
For help with your javascript, please post to r/LearnJavascript instead of here.
For beginner content, please post to r/LearnJavascript instead of here.
For framework- or library-specific help, please seek out the support community for that project.
For general webdev help, such as for HTML, CSS, etc., then you may want to try r/html, r/css, etc.; please note that they have their own rules and guidelines!
r/javascript is for the discussion of javascript news, projects, and especially,
code! However, the community has requested that we not include help and support content, and we ask that you respect that wish.Thanks for your understanding, please see our guidelines for more info.