【问题标题】:alfresco ---- how to add event handler into surf template?alfresco ---- 如何在 surf 模板中添加事件处理程序?
【发布时间】: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


    【解决方案1】:

    您使用的是哪个 IE 版本? 如果是旧版本,尝试通过选项获取选中的值:

    var selectedValue = sel.options[sel.selectedIndex].value;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-09
      相关资源
      最近更新 更多