Home > Article > Web Front-end > Solution when the amount of data in the URL in window.location.href is too large_javascript skills
Let’s talk about the problems we encountered today
A process of exporting excel requires transferring a large amount of data to the background after pressing the button. The initial approach is as follows:
The data above is a very long string.
There is no problem in Firefox and Google Chrome, but it cannot be exported normally in IE9 (I haven’t tried it on other IEs, it should be the same)
The reason for this problem is that various browsers have different length limits for URL parsing. IE is the smallest one, so something went wrong
Microsoft Internet Explorer (Browser)
IE browser has a maximum URL limit of 2083 characters. If this number is exceeded, the submit button will not respond.
Firefox (Browser)
For Firefox browser URL length limit is 65,536 characters
Safari (Browser)
The maximum URL length limit is 80,000 characters.
Opera (Browser)
The maximum URL length is limited to 190,000 characters.
Google (chrome)
The maximum length of URL is limited to 8182 characters
It should also be noted here that the WEB server also has restrictions on the length of the URL! !
Therefore, we can no longer use the Get method. We can only find a way to use post to pass the value, so we have the following solution. I am not sure whether it is appropriate or not. Please give some advice from experts. In short, the function can be realized
The idea is to use post to transfer the long string to the background, save it in the session, and then use window.location.href
in the callback method of postThe code is as follows: