Javascript在IE 11中不起作用,即使警报在IE 11中也不起作用

时间:2019-09-16 07:32:40

标签: javascript browser internet-explorer-11 alert

此代码无法在IE11中正常工作,即使在IE边缘中也无法在其他浏览器中正常工作,但在IE 11中则无法工作。

<script type="text/javascript">

//used for allow unicode and char count
        //var countedTextBox = document.getElementById("counttxt");
        var check1 = document.getElementById('allowunicode');
        var limitVal = document.getElementById('totalchar');
        var textArea1 = document.getElementById('txtmsg');
        var charEntered = document.getElementById('countBody');

        alert("1");
        check1.addEventListener('click', () => {
          if (check1.checked) {
            limitVal.innerHTML = '268';
            checkMaxLimit(268);
          } else {
            limitVal.innerHTML = '620';
            checkMaxLimit(620);
          }
        });
alert("2");
        function checkMaxLimit(limit) {
          if (textArea1 && textArea1.value.length > limit) {
              textArea1.value = textArea1.value.substring(0, limit);
            alert('Sorry! You have reached your maximum message limit.');
          }

        }

        textArea1.addEventListener('keyup', () => {
          var chhhr = textArea1.value.length;
          checkMaxLimit(+limitVal.innerHTML);
          if (chhhr.value >= limitVal) {
            //alert('Maximum value reached');
            charEntered.innerHTML = limitVal.innerHTML;
          }else{
          charEntered.innerHTML = textArea1.value.length;
          }

    });

</script>

以上代码无法正常运行在IE11中,我尝试使用一个简单的警报框,但即使警报也无法在IE11中运行。

0 个答案:

没有答案