Discussion on the problem of garbled characters in iframe page parameters

Discussion on the problem of garbled characters in iframe page parameters
I encountered a very unusual parameter garbled problem. First look at the page

As shown in the picture, there are the same three radios below the monthly indicators.
There is an iframe below the three radios. The effect is that clicking different radios will display different pages.
When clicking, pass the web page address with parameters.

(1) A problem occurred. When switching between "Daily Index" and "Monthly Index", the parameters I passed were Chinese characters, so they were obtained as garbled characters in the background.
So I encode the parameters and decode them with UrlDecode in the background, but I am disappointed to find that the characters are still garbled.
Then I carefully checked the page encoding and found that the page to be opened in the iframe had no encoding.
So add the following sentence to the page

Copy code
The code is as follows:

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

It seems to be working now, switching between the "Daily Indicators" and "Monthly Indicators" web pages can display normally, and the parameters are passed.

(2) But a weird problem occurred. When I switched the radio, an error message appeared and the parameters became garbled characters.
I really don't know what went wrong this time. The same JS method is used for "daily indicators", "monthly indicators" and radio click to switch pages.
In frustration, I randomly clicked around and found the following:
When I clicked "Coalbed Methane", the page was normal. Then when I clicked "Oil Production", the parameters were wrong. When Oil Production was already selected, I clicked "Oil Production" and the page was displayed normally. It shouldn't be like this. Then I compared "Coalbed Methane" and "Oil Production". I have already posted the official page for the "Oil Production" module, but I just posted the Baidu page randomly because the "Coalbed Methane" module has not been made yet. Because of the encoding problem in question (1), the first thing I thought of was the encoding problem. I checked Baidu encoding as follows:

Copy code
The code is as follows:

<metahttp-equiv="content-type" content="text/html;charset=utf-8">

The encoding format is different. So I also put "coalbed methane" on the "oil production" page and removed Baidu.
Um, the page runs normally, but the parameters are not reported and the code is garbled.

Analyze the reason : it seems that when passing parameters, what is obtained is the encoding of the current iframe display page, which has nothing to do with the encoding of the page to be opened.
But this really shouldn't be the case. It's an iframe. I assign a URL and pass parameters to the iframe in its parent page. Why should I care about the current page of the iframe?

<<:  How to deploy MongoDB container with Docker

>>:  Web designers also need to learn web coding

Recommend

Sharing experience on MySQL slave maintenance

Preface: MySQL master-slave architecture should b...

Detailed process of zabbix monitoring process and port through agent

Environment Introduction Operating system: centos...

Introduction and usage examples of ref and $refs in Vue

Preface In JavaScript, you need to use document.q...

How to install and use Ubuntu Docker

Table of contents 1. Automatic installation using...

CocosCreator general framework design resource management

Table of contents Problems with resource manageme...

Solution to the problem that VC6.0 cannot be used when installed on WIN10

VC6.0 is indeed too old VC6.0 is a development to...

A collection of common uses of HTML meta tags

What is a mata tag The <meta> element provi...

Do you know how to use Vue to take screenshots of web pages?

Table of contents 1. Install html2Canvas 2. Intro...

A complete list of meta tag settings for mobile devices

Preface When I was studying the front end before,...

Native js to implement form validation function

Table of contents When developing, analyzing the ...

vue-cli introduction and installation

Table of contents 1. Introduction 2. Introduction...

Use of MySQL DATE_FORMAT function

Suppose Taobao encourages people to shop during D...

Example of building a redis-sentinel cluster based on docker

1. Overview Redis Cluster enables high availabili...

In html table, set different colors and widths for each cell

It is recommended that you do not set the width, h...