以下功能在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);
}
答案 0 :(得分:2)
所有关于IE不支持的textContent
属性&lt; 9.这已在official documentations about the textContent property确认。