Home  >  Article  >  Web Front-end  >  Solution to garbled Chinese parameters passed in get request when loading iframe dynamically_javascript skills

Solution to garbled Chinese parameters passed in get request when loading iframe dynamically_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:49:461374browse

When the user's page needs to dynamically load an iframe,

If the src of the iframe contains Chinese parameters, an encoding error will occur; it must be encoded and then decoded.

Encoding: encodeURI(encodeURI("String containing Chinese"))

Decoding: java.net.URLDecoder.decode("String that needs to be decoded", "utf-8");

Solution

Use encodeURI('Chinese') for encoding operation,

js code:

Copy Code The code is as follows:

$(function() {
$('#frame').attr('src', '${basePath} mi/right.do?bidItemName=' encodeURI('Chinese'));
});

html code
Copy Code The code is as follows:






Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn