如果我写 windows.location="/start/open";
并从服务器端返回 false
我会得到空白页面。
我能捕获这个吗?
最佳答案
没有
windows.location=some URL is just like normal request
但您可以使用 HTTP referer(不要拼写错误)并将客户端重定向回之前所在的页面
例如。在 PHP 中header('Location: ' . $_SERVER['HTTP_REFERER']);
在 ASP.NET 中
Response.Redirect("Location: " +Request.ServerVariables.Get("HTTP_REFERER"));
Java Servlet
response.setHeader("Location: "+ request.getHeader("HTTP_REFERER"));
关于javascript - 我可以在 windows.location 中捕获服务器返回 false 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38246218/