JS document.writeln 输出中文乱码问题的解决方法

本文解决了一个常见的JavaScript编程问题,即在使用document.writeln输出中文时出现的乱码现象。通过将JS文件保存为UTF-8格式,可以有效避免乱码问题,确保中文字符正确显示。
Javascript code
document.writeln(
"why no show 乱码?");     中文直接写在页面上是正常的。。。。。       解决方法:   把js文件用记事本打开,另存为utf-8格式。   网上找的,好用,我试过了。
 

转载于:https://www.cnblogs.com/yangxiaohu1/archive/2011/11/11/JS_document_writeln_luanma.html

javascript: document.writeln("<!doctype html>"); document.writeln("<html>"); document.writeln(""); document.writeln("<head>"); document.writeln(" <meta charset=\'utf-8\'>"); document.writeln(" <meta http-equiv=\'X-UA-Compatible\' content=\'IE=edge\'>"); document.writeln(" <meta name=\'viewport\' content=\'initial-scale=1.0, user-scalable=no, width=device-width\'>"); document.writeln(" <title>设置地图显示要素</title>"); document.writeln(" <link rel=\'stylesheet\' href=\'https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css\' />"); document.writeln(" <style>"); document.writeln(" html,"); document.writeln(" body,"); document.writeln(" #container {"); document.writeln(" width: 100%;"); document.writeln(" height: 100%;"); document.writeln(" }"); document.writeln(""); document.writeln(" #map-features .input-item {"); document.writeln(" height: 2rem;"); document.writeln(" }"); document.writeln(" </style>"); document.writeln("</head>"); document.writeln(""); document.writeln("<body>"); document.writeln(" <div id=\'container\'></div>"); document.writeln(" <div class=\'input-card\' style=\'width:19rem\'>"); document.writeln(" <h4>设置地图显示要素(Features)</h4>"); document.writeln(" <div id=\'map-features\'>"); document.writeln(" <div class=\'input-item\'>"); document.writeln(" <input type=\'checkbox\' name=\'mapStyle\' value=\'bg\' checked>"); document.writeln(" <span class=\'input-text\'>区域面(bg)</span>"); document.writeln(" </div>"); document.writeln(" <div class=\'input-item\'>"); document.writeln(" <input type=\'checkbox\' name=\'mapStyle\' value=\'road\' checked>"); document.writeln(" <span class=\'input-text\'>道路(road)</span>"); document.writeln(" </div>"); document.writeln(" <div class=\'input-item\'>"); document.writeln(" <input type=\'checkbox\' name=\'mapStyle\' value=\'building\' checked>"); document.writeln(" <span class=\'input-text\'>建筑物(building)<
最新发布
08-12
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值