Input Chinese into the div edit box under IE8, and intercept the problem of substring

A div editable box. I need to save the contents of the input box as the first ten characters when the input character is greater than 10. The following code is fine in Google browser, but when I type "11111111111" in IE8, it can be intercepted normally, but the result displayed by typing "ah" will become an "ah".
wait online, solutions, and I"m not sure where the problem is.

<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title></title>
        <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>

    </head>

    <body>
        <div id="myDiv" contenteditable="true" style="width: 100%; height: 80px; border: 1px solid -sharpCCC;" onblur="myDivCalc()" onkeyup="myDivCalc()"></div>
        <script>
            function myDivCalc(){
                var str = $("-sharpmyDiv").text();
                if(str.length<=10){
                    
                }else{
                    var strJ = str.substring(0,10);
                    $("-sharpmyDiv").text(strJ);
                    set_focus(document.getElementById("myDiv"))
                }
            }
            //div
            function set_focus(el){
                //el=el[0];  //jquery dom
                el.focus();
                if($.support.msie)
                {
                    var range = document.selection.createRange();
                    this.last = range;
                    range.moveToElementText(el);
                    range.select();
                    document.selection.empty(); //
                }
                else
                {
                    var range = document.createRange();
                    range.selectNodeContents(el);
                    range.collapse(false);
                    var sel = window.getSelection();
                    sel.removeAllRanges();
                    sel.addRange(range);
                }
            }
        </script>
    </body>

</html>
Mar.31,2021

has not played ie browser, but you can try this method


in the case of passing positive parameters, the behavior of, slice () and substring () is consistent. The, substr () method is easy to be confused on the second parameter

.

in the case of passing negative parameters, the, slice () method is added by the length of the string. In line with the general thinking, it is easy to have problems when the second parameter of, substring () is converted to 0, and the starting position will be easily changed. In the case of negative values of the, substr () method, there will be IE compatibility problems.


I have changed the input method of the system under IE8 from the original Microsoft input method to Sogou Input. No problem.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b39f19-2c1da.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b39f19-2c1da.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?