When using the SPRINGMVC framework, it is sometimes necessary to use window.location.href in JS to request a URL, such as the following path:
window.location.href = ' forecast/download.do '
In Google Chrome, the actual request path is: Project name/forecast/download.do
When accessed under IE, there are several layers of folders in the middle:
This is caused by various browsers handling different methods when using Window.localtion.href to request relative paths
IE is jumping from the current current path
Google is starting from the root directory to jump
So the best way to do this is to use absolute paths so that they all jump from the root directory:
<script type= "Text/javascript" > Function GetPath () {var path = "<%=path%>"; return path;} </script>
<script type= "Text/javascript" >var path = GetPath () + "/"; var url = path+ ' forecast/download ' window.location.href = encodeURI (URL);</script>
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
SPRINGMVC framework in JS use window.location.href request URL when IE incompatibility problem resolution