form提交时accept-charset属性在IE及Edge下不起作用解决方案

问题描述

我的页面是utf-8编码

目标页面是EUC-JP编码

即使已经设置了accept-charset="EUC-JP",提交后IE 和 Edge下还是乱码

解决方案:

1. isIE方法中不仅判断IE,还判断Edge

 <SCRIPT>

        function isIE() { //ie?
            if (!!window.ActiveXObject || "ActiveXObject" in window || navigator.userAgent.indexOf("Edge") > -1)
                return true;
            else
                return false;
        }
    </SCRIPT>
    <form action="http://www.smpho.com/shop/shopbrand.html" method="post" name="search" accept-charset="EUC-JP" onsubmit="if(isIE())document.charset='EUC-JP'">
        <input name="search" size="20" class="search_input">
        <button type="submit">検索する</button>
    </form>

  

原文地址:https://www.cnblogs.com/shihao316558512/p/7592839.html