解决ie浏览器对get请求携带的中文参数没有进行编码的问题

本文链接:https://blog.csdn.net/qq_43612658/article/details/89504751

<script>

    function isIE(){
        //获取当前浏览器相关信息
        var explorer = window.navigator.userAgent.toLowerCase() ;
        //判断是否是ie浏览器
        if (explorer.indexOf("msie") >= 0 || explorer.indexOf("rv:11.0) like gecko") >= 0) {
        return true;
    }else {
      false;
    }
    }
    window.onload = function () {
        if(isIE()){
            //在是IE浏览器的情况下,对中文请求参数编码
            var str = document.getElementById("ww").href;
            var str = encodeURI(str);
            document.getElementById("ww").href = str;
        }
    };
    </script>

下载excel文件遇到IE不兼容问题:实质是请求参数编码问题

 $(document).on('click','#resetBtnaa',function (){
        var hygxsj=$('#hygxsj').val()
        var demarcateStatus=$("#demarcateStatus option:selected").html()
        var verifyStatus=$("#verifyStatus option:selected").html()
         
        var a = document.createElement('a');
        var str= '../admin/npl-website/negn/data/exportUserPage?hygxsj='+hygxsj+'&demarcateStatus='+demarcateStatus+'&verifyStatus='+verifyStatus;
        str=encodeURI(str)
        a.href =  str;
        $("body").append(a);//修复firefox中无法触发click
        a.click();
        $(a).remove();
  
    })

添加了encodeURL问题解决!!!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章