Why does "string" [0] behave differently on ie8 + IIS7.5 than other browsers or a local file?

Consider the following Html file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>test</title>
        <style type="text/css">

        </style>
    </head>
    <body>
        <script type="text/javascript">
            alert('' +
                '\'test\'[0] = \'' + 'test'[0] + '\'\n' +
                '\'test\'.charAt(0) = \'' + 'test'.charAt(0) + '\'\n'
            );
        </script>
    </body>
</html>

When I open this file on my local machine, it gives the following result (both in ie8 and in Chrome):

'test'[0] = 't'
'test'.charAt(0) = 't'

When I put this file in IIS7.5, I still get the same result in Chrome, but ie8 gives the following result:

'test'[0] = 'undefined'
'test'.charAt(0) = 't'

How is this possible?

+3
source share
2 answers

OK , . Internet Explorer ( , ) . ie8, head:

<meta http-equiv="X-UA-Compatible" content="IE=edge" > <!-- IE8 mode -->

"" > " "

.

: - ie8, . , .

EDIT2: sv_in . IE=edge .

0

Jan, , - doctype .

<!DOCTYPE html>

HTML5 doctype, .

0

Source: https://habr.com/ru/post/1770685/


All Articles