javascript - 文字不会出现在 IE8 及更低版本中

标签 javascript html internet-explorer-8

下面的函数在 IE 9 及更高版本中工作正常,但文本不会出现在 IE 8 及更低版本中。

html:

<body onLoad="BuildBrwsrInfoMsg();" style="background:   url('../images/BeachBackground.jpg'); margin-top:0; " id="LoadingDisplay"  >

脚本:

function BuildBrwsrInfoMsg()
                {
    var maindiv = document.getElementById('Background-Header');
    var div = document.createElement('div');
    div.setAttribute('id', 'browserInfo');  
    var spanBrwsrNameVersion = document.createElement('span');
    spanBrwsrNameVersion.textContent = "Browser Not Supported - You are using ("+ bowser.name + ' ' + bowser.version + ")";
    spanBrwsrNameVersion.setAttribute('class', 'BrowersTitle' );
    div.appendChild(spanBrwsrNameVersion);
    var spanBrwsrMsg = document.createElement('span');
    spanBrwsrMsg.textContent = "This browser may not be compatible with our website. For best results, it is suggested that you upgrade to the latest version. To download the latest version Click";
    spanBrwsrMsg.setAttribute('class', 'BrowersDescription' );
    div.appendChild(spanBrwsrMsg);

    var hideBtn = document.createElement('input');
    hideBtn.setAttribute('id', 'btnHideMsg');
    hideBtn.setAttribute('type', 'submit');
    hideBtn.setAttribute('value', 'Hide Message');
    div.appendChild(hideBtn);

        maindiv.insertBefore(div, maindiv.firstChild);                                          
  }

最佳答案

这都是关于 IE < 9 不支持 textContent 属性。official documentations about the textContent property 上已证实这一点。 .

关于javascript - 文字不会出现在 IE8 及更低版本中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23281006/

相关文章:

JavaScript 窗口对象元素属性

javascript - YouTube上的Wonder Plugin Carousel多个播放列表请求崩溃

html - Bootstrap 表单布局,2 列

javascript - 仅使用纯 JavaScript(无 jQuery)向给定纯文本 HTML 的 DOM 添加元素

html - IE6/7/8 中的 innerHTML 问题?

internet-explorer - IE8 只打印网页的第 1 页

javascript - Three.js - 一起使用视口(viewport)和 EffectComposer

javascript - 使用自定义原型(prototype)在 javascript 中创建函数

javascript - 添加表格行和单元格

jquery - IE8中的CSS定位令人头疼