SPRINGMVC framework in JS use window.location.href request URL when IE incompatibility problem resolution

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.