Вопрос

In my below, it works fine upto IE9, but not in IE10+:

function createList() {

  try {

    var listObj = document.getElementById('dialedList');
    //document.getElementById('dialedDiv').style.display = "inline";
    var list = opener.dialedNumbers; // This is array
    //alert("list : "+list);
    for (var i = 0; i < list.length; i++) {

      //alert(list[i])
      if (list[i] != undefined && list[i] != null && list[i] != "") {
        alert("come");
        var li = document.createElement("<li>");
        alert("not come");
        li.innerHTML = list[i];
        li.onclick = function () {
          //alert(this);
          document.getElementById('screen').value = this.innerHTML;
          document.getElementById('screen').focus();
        };
        li.onmouseover = function () {

          this.style.backgroundColor = "#719FE5";
          this.focus();
        };
        li.onmouseout = function () {

          this.style.backgroundColor = "white";
          this.focus();
        };
        listObj.appendChild(li);
      }
    }
  } catch (e) {
    alert(e.description);
    alert(e.message);
  }
}
Это было полезно?

Решение

createElement doesn't accept HTML, it accepts an element name ("tag name"). So you don't include the angle brackets:

var li = document.createElement("li");

If you've had other browsers accepting the previous version, they were just being tolerant.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top