【发布时间】:2009-08-21 04:02:05
【问题描述】:
<div class="yui-gd">
<div class="yui-u first"><label for="${args.htmlid}-addContent">${msg("label.HowToAddContent")}:</label></div>
<div class="yui-u">
<select id="addContent" name="addContent" onchange="dropdown(this)">
<option value="1" selected="selected">${msg("label.generateFromDescription")}</option>
<option value="2">${msg("label.uploadFile")}</option>
</select>
</div>
</div>
<script type="text/javascript">//<![CDATA[
function dropdown(sel){
//if(document.getElementById("addContent").value == "1")
if(sel.value == "0"){
document.getElementById('desc').style.display = 'block'
}
else {
document.getElementById('desc').style.display = 'none'
}
}
//]]></script>
我写它是因为我想将事件处理程序添加到选择框中,它在 Firefox 中运行良好,但在 IE 中它总是抛出空异常。 即使我使用了 attachEvent ,它仍然无法在 IE 中工作。 如果我在上面使用 document.getElementById("addContent") ,它总是会抛出空异常! 但是所有这些东西在 Firefox 中都运行良好!
谁能告诉我为什么? 提前致谢!
【问题讨论】:
标签: javascript event-handling alfresco surf