When the iframe is loaded dynamically the get request passes the Chinese parameter garbled solution
- 2020-03-30 02:50:20
- OfStack
When a user's page needs to load an iframe dynamically,
If the packet transmission Chinese parameter in the SRC of the iframe is encoded incorrectly; It must be encoded and then decoded.
EncodeURI (encodeURI(" string containing Chinese "))
Decoding: java.net.URLDecoder.decode (" need to decode the string ", "utf-8");
The solution
Using encodeURI(' Chinese ') for coding operations,
Js code:
The HTML code
If the packet transmission Chinese parameter in the SRC of the iframe is encoded incorrectly; It must be encoded and then decoded.
EncodeURI (encodeURI(" string containing Chinese "))
Decoding: java.net.URLDecoder.decode (" need to decode the string ", "utf-8");
The solution
Using encodeURI(' Chinese ') for coding operations,
Js code:
$(function() {
$('#frame').attr('src', '${basePath}mi/right.do?bidItemName=' +encodeURI(' Chinese '));
});
The HTML code
<html>
<body>
<iframe src="" scrolling="no" frameBorder=0 id="frame"></iframe>
</body>
</html>