Home > Web Front-end > JS Tutorial > 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
Release: 2016-05-16 16:49:46
Original
1437 people have browsed it

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:






Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template