locked
Internet Explorer 11 -> JS -> DOM. Different lists of attributes of HTML tags from local HTML file and from shared folder. RRS feed

  • Question

  • HTML file for reproducing:

    <html>
    <head>
        <meta charset="UTF-8">
    </head>
    <body>
    <label for="pet-select">Choose an item:</label>
    <select name="list" id="selectId">
        <option disabled value="text hello">Item 01</option>
        <option value="item02">Item 02</option>
        <option value="item03">Item 03</option>
        <option disabled="Redundant value" value="item04">Item 04</option>
        <option value="item05">Item 05</option>
    </select>
      
    <br>
    <button id="btnId" onclick="getInfo()">INFO</button>
    <br>
    <br>
    <div id="resultId">RESULT</div>
      
    <script>
    function getInfo(){
      var selectCtrl = document.getElementById('selectId');
      var options = selectCtrl.options; 
      var textCtrl = document.getElementById('resultId');
       
      for (var i = 0; i < options.length; ++i){ 
        var option = options[i];
        var tmpTxt = '\n//=====\n';
        tmpTxt += 'option.attributes: ' + option.attributes + '[' + i + ']\n';
        tmpTxt += 'option.text = ' + option.text + '\n';
        tmpTxt += 'option.disabled = ' + option.disabled + '\n';
        tmpTxt += 'option.hideFocus = ' + option.hideFocus + '\n';
        tmpTxt += 'option.spellcheck = ' + option.spellcheck + '\n';
        tmpTxt += 'option.tabIndex = ' + option.tabIndex + '\n';
        tmpTxt += 'option.attributes.lenght = ' + option.attributes.length + '\n';
        for (var j = 0; j < option.attributes.length; ++j) {
            var a = option.attributes[j];
            tmpTxt += 'attribute[' + j + '] ' + a.name + ' : ' + a.value + '\n';
        }
        textCtrl.innerText += tmpTxt ;
      }
     }
    </script>
    </body>
    </html>

    open from local drive and press INFO:

    RESULT
    //=====
    option.attributes: [object NamedNodeMap][0]
    option.text = Item 01
    option.disabled = true
    option.hideFocus = false
    option.spellcheck = true
    option.tabIndex = 0
    option.attributes.lenght = 2
    attribute[0] disabled :
    attribute[1] value : text hello
    //=====
    option.attributes: [object NamedNodeMap][1]
    ...
    ...

    Open from shared folder and press INFO:

    RESULT
    //=====
    option.attributes: [object][0]
    option.text = Item 01
    option.disabled = true
    option.hideFocus = false
    option.spellcheck = true
    option.tabIndex = 0
    option.attributes.lenght = 130
    attribute[0] onmsanimationiteration : null
    attribute[1] onbeforeeditfocus : null
    attribute[2] aria-haspopup :
    attribute[3] onbeforeactivate : null
    attribute[4] onbeforepaste : null
    attribute[5] oncopy : null
    attribute[6] onmouseleave : null
    attribute[7] ondragstart : null
    attribute[8] onmsanimationend : null
    attribute[9] ondatasetcomplete : null
    attribute[10] aria-required :
    attribute[11] aria-expanded :
    ...
    ...
    attribute[125] dataFld : null
    attribute[126] onmousewheel : null
    attribute[127] label :
    attribute[128] selected : false
    attribute[129] value : text hello
    //=====
    option.attributes: [object][1]

    Local file: option.attributes: [object NamedNodeMap][0]
    File from shared folder: option.attributes: [object][0]

    In Chrome there is no difference, only attributes from HTML.

    Could you explain this behavior of IE, please?


    • Edited by Andrei.Rudik Thursday, December 10, 2020 5:34 PM
    Thursday, December 10, 2020 5:33 PM

All replies