【发布时间】:2009-06-03 16:17:52
【问题描述】:
我正在努力:
document.getElementById("header-text").innerHTML = "something interesting";
除了 Opera 之外的所有浏览器都可以正常工作(我正在运行最新版本)。
浏览互联网时,我发现有人说 Opera 不支持 innerHTML。这听起来不对。
任何指针?
谢谢
编辑:这是我要获取的 id
<div id="header-text" class="picture-text">
<!--[if gt IE 5]>ugly hack<![endif]-->
Some text generated server side
<!--[if gt IE 5]>ugly hack<![endif]-->
</div>
Edit2:我有同样的问题:
<div id="header-text" class="picture-text">
Static text
</div>
编辑3:
<body onload="intialize();">
function intialize() {
operaHeaderFix();
}
function operaHeaderFix(){
if(window.opera) {
/*opera specific action*/
document.getElementById("picture-line-wrapper").style.position="relative";
document.getElementById("picture-line-wrapper").style.top="0px";
document.getElementById("picture-line-wrapper").style.marginTop="-230px";
document.getElementById("picture-line").style.padding="1px";
document.getElementById("header-text").innerHTML = "<div style='margin:220px 0px 0px 20px;'>"+document.getElementById("header-text").innerHTML+"TEST</div>";
}
}
Edit4:如果我删除 if(window.opera),它将在 FF 和 IE 中正常运行
【问题讨论】:
-
你有什么确切版本的 Opera?
-
我在 Windows XP 上运行 9.64
-
我刚刚更新到 9.64(在 XP 上)并运行了你的静态 div/JS 测试......它运行良好。一定有其他事情发生。
-
发生了一些真正的问题,因为以上所有内容都对我有用...(编辑 1-4)
-
这在 Opera 中也适用于我。在这一点上,我只能建议卸载并重新安装 Opera,然后看看它是否有效。
标签: javascript cross-browser opera