When the user's page needs to dynamically load an iframe,
If the Chinese parameters are transmitted in the src of the iframe, there will be an encoding error; it must be encoded and then decoded.
Encode: encodeURI(encodeURI("contains Chinese string"))
Decoding: java.net.URLDecoder.decode("string that needs to be decoded","utf-8");
Solution
Use encodeURI('Chinese') to perform encoding operations,
js code:
The code copy is as follows:
$(function() {
$('#frame').attr('src', '${basePath}mi/right.do?bidItemName=' +encodeURI('Chinese'));
});
html code
The code copy is as follows:
<html>
<body>
<iframe src="" scrolling="no" frameBorder=0 id="frame"></iframe>
</body>
</html>