2010-11-05 82 views
2

我遇到了一個頁面已被加載後自動點擊一個元素,所以我實現了以下代碼:文檔準備好()不工作在Firefox中給DOM爲空元素... IE7工作正常

<script type="text/javascript"> 
    var $j = jQuery.noConflict(); 
    $j(document).ready(function() { 
     document.getElementById('handler2').click(); 
    }); 
</script> 

哪個在IE7中工作正常,但不是Firefox。當我在firefox 3中運行腳本時,出現以下錯誤:document.getElementById("handler2") is null

我認爲這是空的,因爲頁面(在firefox中)並未完全將id「handler2」所在的位置加載到DOM ...但我不明白。爲什麼它會在IE中加載DOM,但不是Firefox?我閱讀了一些文章,指出Firefox在firefox3中對javascript的執行做了一些改變,這可能會導致問題。也許「document.ready」在firefox3中執行得太快了?

任何人有任何想法或如何解決這個問題?

在此先感謝您的幫助。


這是不是最好的輸出,但完整的源代碼是太大,計算器接受。如果您搜索「handler2」,您應該在標籤內找到它。謝謝你的幫助。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML Strict//EN"><META http-equiv="Content-Type" content="text/html; charset=utf-8"> <HTML><BODY id="srp" style="MARGIN-TOP: 2px; MARGIN-LEFT: 2px; CURSOR: default; COLOR: black; MARGIN-RIGHT: 2px; BACKGROUND-COLOR: white"><TABLE id="mainTable" height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0" valign="top"><TBODY><TR><TD class="contentcell" vAlign="top" width="100%" height="100%"><TABLE class="manager" id="searchManager" cellSpacing="0" cellPadding="0"><TBODY><TR><TD class="managerBody" id="managerBody"><TABLE class="searchManager setHeight panelGroup" id="managerTable" style="HEIGHT: 536px" cellSpacing="0" cellPadding="0"><TBODY><TR><TD class="panelFrame filters" id="secondaryPod"><DIV class="filters setHeight" id="filters" style="HEIGHT: 503px"><DIV class="wrapper" id="filtersWrapper"><DIV class="content setHeight" id="searchFilters" style="HEIGHT: 503px"><DIV class="foldersPanel setHeight" id="foldersPanel" style="HEIGHT: 503px"><DIV class="content panelBorder foldersTree" oncontextmenu="return false;" id="foldersTree" style="WIDTH: 267px; HEIGHT: 150px"><DIV id="node1sub" style="DISPLAY: block"><DIV id="node2"><NOBR> <IMG id="handler2" style="VERTICAL-ALIGN: middle; WIDTH: 19px; HEIGHT: 20px" src="images/treeimages/plus_last.gif" /> </NOBR></DIV></DIV></DIV></DIV></DIV></DIV></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></BODY></HTML> 

這裏的源代碼。這是在tomcat上使用第三方.jsp。你將無法看到擴展列表,因爲一個java進程正在創建它,但是有一個元素「handler2」帶有一個我正在觸發的click事件。我希望這不是太多的代碼來解決這個問題。我的腳本處於最底層。這.JSP頁面使用prototype.js,這就是爲什麼我用的是「沒有衝突」,所以我可以使用jQuery ...我不知道的prototype.js

源代碼:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
<%@ taglib uri="/WEB-INF/jasperserver.tld" prefix="js" %> 
<%@ taglib uri="/spring" prefix="spring" %> 
<%@ taglib prefix="authz" uri="http://www.springframework.org/security/tags" %> 
<%@ page errorPage="/WEB-INF/jsp/JSErrorPage.jsp" %> 
<%@ page import="org.apache.commons.lang.StringEscapeUtils" %> 

<html> 
<head> 
    <link href="${pageContext.request.contextPath}/stylesheets/table.css" rel="stylesheet" type="text/css"> 
    <link href="${pageContext.request.contextPath}/stylesheets/customtooltip.css" rel="stylesheet" type="text/css"> 
    <link href="${pageContext.request.contextPath}/stylesheets/std_treelook.css" type="text/css" rel="stylesheet"> 
    <link href="${pageContext.request.contextPath}/stylesheets/manager.css" rel="stylesheet" type="text/css"> 
    <link href="${pageContext.request.contextPath}/stylesheets/search.css" rel="stylesheet" type="text/css"> 
    <link href="${pageContext.request.contextPath}/toolkit/parts/css/infiniteScroll.css" rel="stylesheet" type="text/css"/> 
    <link href="${pageContext.request.contextPath}/toolkit/parts/css/optionSet.css" rel="stylesheet" type="text/css"/> 
    <link href="${pageContext.request.contextPath}/toolkit/parts/css/tabularList.css" rel="stylesheet" type="text/css"/> 
    <link href="${pageContext.request.contextPath}/stylesheets/search.css" rel="stylesheet" type="text/css"/> 
    <link href="${pageContext.request.contextPath}/stylesheets/searchMenus.css" rel="stylesheet" type="text/css" /> 
    <!--[if IE]> 
     <link href="${pageContext.request.contextPath}/stylesheets/search-ie-specific.css" rel="stylesheet" type="text/css" media="screen" /> 
    <![endif]--> 
    <!--[if IE]> 
     <link href="${pageContext.request.contextPath}/stylesheets/manager/ie-specific.css" rel="stylesheet" type="text/css" media="screen" /> 
    <![endif]--> 
    <!--[if IE 7]> 
     <link href="${pageContext.request.contextPath}/stylesheets/manager/ie7-specific.css" rel="stylesheet" type="text/css" media="screen" /> 
    <![endif]--> 

    <script language="JavaScript" src="${pageContext.request.contextPath}/scripts/edition.js"></script> 
    <script language="JavaScript" src="${pageContext.request.contextPath}/scripts/dialog.js"></script> 
    <script language="JavaScript" src="${pageContext.request.contextPath}/scripts/checkbox-utils.js"></script> 
    <script language="JavaScript" src="${pageContext.request.contextPath}/scripts/table.js"></script> 
    <script language="JavaScript" src="${pageContext.request.contextPath}/scripts/customTooltip.js"></script> 
    <script language="JavaScript" src="${pageContext.request.contextPath}/scripts/nanotree.js"></script> 
    <script language="JavaScript" src="${pageContext.request.contextPath}/scripts/treesupport.js"></script> 

    <%--<script src="${pageContext.request.contextPath}/toolkit/utilities/common.js" type="text/javascript"></script>--%> 
    <script src="${pageContext.request.contextPath}/toolkit/parts/javascript/tabularList.js" type="text/javascript"></script> 
    <script src="${pageContext.request.contextPath}/toolkit/parts/javascript/infiniteScroll.js" type="text/javascript"></script> 
    <script src="${pageContext.request.contextPath}/scripts/ajax.js" type="text/javascript"></script> 
    <script src="${pageContext.request.contextPath}/scripts/rootObjectModifier.js"></script> 
    <script src="${pageContext.request.contextPath}/scripts/search/dialog.js" type="text/javascript"></script> 
    <script src="${pageContext.request.contextPath}/scripts/search/components.js" type="text/javascript"></script> 
    <script src="${pageContext.request.contextPath}/scripts/search/search.js" type="text/javascript"></script> 
    <script src="${pageContext.request.contextPath}/scripts/search/menu.js" type="text/javascript"></script> 
    <script src="${pageContext.request.contextPath}/scripts/search/dnd.js" type="text/javascript"></script> 
    <script src="${pageContext.request.contextPath}/scripts/search/resourceactions.js" type="text/javascript"></script> 
    <script src="${pageContext.request.contextPath}/scripts/search/folderactions.js" type="text/javascript"></script> 
    <script src="${pageContext.request.contextPath}/scripts/search/bulkactions.js" type="text/javascript"></script> 
    <script src="${pageContext.request.contextPath}/scripts/search/searchLayoutManager.js" type="text/javascript"></script> 
<script src="${pageContext.request.contextPath}/scripts/e.js" type="text/javascript"></script> 

    <script type="text/javascript"> 

     webHelpModule.currentContext = "search"; 

    </script> 

</head> 

<body id="srp" > 

<table id="searchManager" class="manager" cellspacing="0px" cellpadding="0px"> 
    <tr><td class="fsection managerTitle"></td></tr> 
    <tr> 
     <td id="managerBody" class="managerBody"> 
      <table id="managerTable" class="searchManager setHeight panelGroup" cellspacing="0px" cellpadding="0px"> 
       <tr style="height:1px;"> 
        <td style="height:1px;"id="filtersHeader" class="panelHeader mainListFrame">&nbsp; 
     <!--COMMENTED BY AARON removes the label "SEARCH" 
         <h2> 
     <spring:message code="SEARCH_FILTERS" javaScriptEscape="true"/> 
     </h2> 
     --> 
        </td> 
        <td style="height:1px;" class="panelHeader sizerFrame" > </td> 
        <td style="height:1px;" class="panelHeader">&nbsp; 
     <!--COMMENTED BY AARON removes the label "REPOSITORY" 
         <h2> 
     <spring:message code="SEARCH_RESOURCE_TITLE" javaScriptEscape="true"/> 
     </h2> 
     --> 
        </td> 
       </tr> 
       <tr> 
        <td id="secondaryPod" class="panelFrame filters"> 
         <div id="filters" class="filters setHeight"> 
          <div id="filtersWrapper" class="wrapper"> 
           <div id="searchFilters" class="content setHeight"> 
            <div id="foldersPanel" class="foldersPanel setHeight"> 
             <!--COMMENTED BY AARON to remove the header class which draws the box around the "include subfolders checkbox" see tag below 
      <div class="header"> 
      --> 
      <div class=""> 
              <!-- COMMENTED BY AARON Hides the SEARCH TEXT BOX options for filtering 
              <div id="js-search-secondary-control" class="js-search-control" style="width: 100%"> 
      <table cellpadding="0" cellspacing="0"> 
                <tr> 
                 <td> 
                  <input id="secondarySearchText" name="searchText" type="text" class="rndCorners-all default" value=""/> 
                  <div id="secondaryClearBtn" title="<spring:message code='SEARCH_BOX_CLEAR_LABEL'/>" class="clear setHidden">&nbsp;</div> 
                 </td> 
                 <td class="button"> 
                  <button id="secondarySearchBtn" class="submit up" title="<spring:message code='SEARCH_BOX_SEARCH_LABEL'/>" type="submit"> 
                   <spring:message code='SEARCH_BOX_SEARCH_LABEL'/> 
                  </button> 
                 </td> 
                </tr> 
               </table> 

              </div> 
      --> 


             </div> 
             <div id="foldersTree" class="content panelBorder foldersTree" oncontextmenu="return false;"></div> 
      <!-- Controls the Checkbox for "Include Subfolders" 
      by moving the div below to "after the <div id="foldersTree"> it effectively hides the checkbox, other wise 
      the whole folder of reports gets hidden if u try to comment it 
      --> 
              <div > 
               <input id="searchMode" type="checkbox" class="modeSelector setHidden"/> 
               <span id="searchModeLabel" class="checkboxLabel setHidden"> 
      <spring:message code='SEARCH_SWICH_MODE'/> 
      </span> 
              </div> 
            </div> 
            <div id="filtersPanel" class="filtersPanel filterList panelBorder" style="display:none;"></div> 

     <table id="filtersTable" class="panelBorder" cellpadding="0" cellspacing="0"> 
             <tbody> 
             <tr> 
              <td class="panelHeader mainListFrame"> 
               <h2> 
      <!--COMMENTED BY AARON . Removes the "Refine Label" 
      <spring:message code="SEARCH_REFINE" javaScriptEscape="true"/> 
      --> 
      </h2> 
              </td> 
             </tr> 
             <!--COMMENTED BY AARON. Removes the first top row for the REFINE category 
      <tr> 
              <td class="panelBorder top">&nbsp;</td> 
             </tr> 
      --> 
             </tbody> 
             <!----> 
      <tbody> 
             </tbody> 

            </table> 

           </div> 
          </div> 
         </div> 
        </td> 
        <td class="sizerFrame"> 
     <!--ADDED BY AARON. Added the "Style" portion to add a different box around the resizer 
     <div id="vSizer" class="setHeight sizer vertical"> 
     --> 
         <div id="vSizer" class="setHeight sizer vertical" style="border-width:1px;border:#F0F0F0;border-style:solid;"> 
         </div> 
        </td> 
        <td id="primaryPod" class="panelFrameLast result"> 
         <div id="result" class="panelBorder setHeight setWidth"> 
          <div id="resultWrapper" class="wrapper"> 
           <div class="toolbar container labels"> 
            <div class="buttonSet fl"> 
             <input id="bulkCheckbox" class="bulkSelector" value="" type="checkbox"> 
            </div> 
            <div id="bulkBar" class="buttonSet fl"> 
            </div> 
            <%--<div id="createResourceBar" class="buttonSet fl">--%> 
             <%--<button id="createResource" class="toolbarBtn complex up">--%> 
              <%--<span class="label">&nbsp;</span>--%> 
              <%--<span class="menuSignal">&nbsp;</span>--%> 
             <%--</button>--%> 
            <%--</div>--%> 
            <div class="cb"></div> 
           </div> 
           <div class="toolbar secondary bulkBar"> 
            <div id="filterPath" class="container" style="float:left;"> 
             <ul class="tabSet optionSet"></ul> 
            </div> 
            <div id="searchSort" class="container"> 
             <ul id="sortBar" class="tabSet optionSet"></ul> 
            </div> 
            <div style="float:none;"> 
            </div> 
           </div> 

           <div id="" class="<%--wrapper--%> tabularList setMyWidth" <%--style="display: none"--%>> 

            <table id="allResultsHeaderTable" class="setMyWidth" cellspacing="0px" cellpadding="0px"> 
             <thead> 
             <tr class="headers"> 
              <th class="bulkSelector" scope="col"></th> 
              <th class="scheduled" scope="col"></th> 
              <th class="expander" scope="col"></th> 
              <th class="name" scope="col"></th> 
              <th class="description" scope="col"></th> 
              <th class="modifiedDate" scope="col"></th> 
             </tr> 
             </thead> 
             <tbody class="resultGroup"> 
             <tr id="allResultsHeader" style="display:none;" class="content"> 
              <th class="typeHeader" colspan="6"><h4 id="resourceName" class="textAccent"></h4></th> 
             </tr> 
             </tbody> 
            </table> 

           </div> 


<!--COMMENTED BY AARON: THIS IS THE BEGINNING OF THE PANEL THAT HAS THE LIST OF REPORTS--> 

           <div id="resultContent" class="content setMyWidth setHeight" oncontextmenu="return false;"> 
            <div id="resourceList" class="wrapper tabularList setHidden"> 
             <table id="resultsTable" class="" cellpadding="0" cellspacing="0"> 
              <thead> 
              <tr class="headers"> 
               <th class="bulkSelector" scope="col"></th> 
               <th class="scheduled" scope="col"></th> 
               <th class="expander" scope="col"></th> 
               <th class="name" scope="col"></th> 
               <th class="description" scope="col"></th> 
               <th class="modifiedDate" scope="col"></th> 
              </tr> 
              </thead> 
              <tbody class="resultGroup"> 
              <tr colspan="5"></tr> 
              </tbody> 
             </table> 
            </div> 

            <div id="allList" class="wrapper tabularList setHidden"> 

             <table id="allResultsTable" cellspacing="0px" cellpadding="0px"> 
              </thead> 
              <tbody class="resultGroup"> 
              <!--COMMENTED BY AARON. To remove an extra row 
      <tr colspan="5"></tr> 
      --> 
              </tbody> 
             </table> 
            </div> 
           </div> 

<!--COMMENTED BY AARON: END OF THE PANEL THAT HAS THE LIST OF REPORTS--> 

          </div> 
         </div> 
        </td> 
       </tr> 
      </table> 
     </td> 
    </tr> 
</table> 

<div id="ajaxbuffer" style="display: none;"></div> 
<%@ include file="menu.jsp" %> 
<%@ include file="../repository/dragAndDrop.jsp" %> 
<%@ include file="folder.jsp" %> 

<div id="errorMsgBox" class="dialogFrame searchModalDialog" style="display: none; position: absolute;"> 

    <div class="dialogHeader" onMouseDown="dialogOnMouseDown(event);"> 
     <div id="errorMsgBoxTitle" class="dialogHeaderTitle"><spring:message code="SEARCH_CONFIRMATION_MESSAGE_BOX_TITLE"/></div> 
    </div> 

    <div class="dialogContent deleteDialogContent" onKeyPress="cancelEventBubbling(event);"> 
     <div id="errorMsgBoxMessage" class="dialogMessages wrap"></div> 

     <div class="dialogButtons"> 
      <input id="errorMsgBoxOk" value="OK" type="button" class="dialogButton"> 
     </div> 
    </div> 

</div> 

<div id="confirmBox" class="dialogFrame searchModalDialog" style="display: none; position: absolute;"> 

    <div class="dialogHeader" onMouseDown="dialogOnMouseDown(event);"> 
     <div id="confirmBoxTitle" class="dialogHeaderTitle"><spring:message code="SEARCH_CONFIRMATION_MESSAGE_BOX_TITLE"/></div> 
    </div> 

    <div class="dialogContent deleteDialogContent" onKeyPress="cancelEventBubbling(event);"> 
     <div id="confirmBoxMesage" class="dialogMessages"></div> 

     <div class="dialogButtons"> 
      <input id="confirmBoxOk" value="Yes" type="button" class="dialogButton"> 
      <input id="confirmBoxCancel" value="No" type="button" class="dialogButton"> 
     </div> 
    </div> 

</div> 

<form id="redirectForm" action="flow.html" method="post" onSubmit="return false;" style="display:none;"> 
    <input id="_flowExecutionKey" name="_flowExecutionKey" value="${flowExecutionKey}" type="hidden" /> 
    <input id="_eventId" name="_eventId" value="redirect" type="hidden" /> 
    <input id="flowParams" name="flowParams" value="" type="hidden" /> 
</form> 

<!-- Page Specific Scripts --> 
<script id="messagesScript" type="text/javascript"> 
    <c:forEach var="type" items="${searchConfiguration.labelsForTypes}" 
    >messages["properties.type.${type}"] = '<spring:message code="resource.${type}.label" javaScriptEscape="true"/>'; 
    </c:forEach> 

    <c:forEach var="type" items="${searchConfiguration.supportedTypes}" 
    >messages["${type}"] = '<spring:message code="SEARCH_${type}" javaScriptEscape="true"/>'; 
    </c:forEach> 

    <c:forEach var="mode" items="${searchConfiguration.modes}" 
    >messages["mode.<c:out value="${mode}"/>"] = '<spring:message code="SEARCH_MODE_${mode}" javaScriptEscape="true"/>'; 
    </c:forEach> 

    <c:forEach var="type" items="${searchConfiguration.typeFilter.types}" 
    >messages["${type.labelId}"] = '<spring:message code="${type.labelId}" javaScriptEscape="true"/>'; 
    </c:forEach> 

    <c:forEach var="customFilter" items="${searchConfiguration.customFilters}"> 
     <c:forEach var="option" items="${customFilter.options}"> 
     messages["${option.labelId}"] = '<spring:message code="${option.labelId}" javaScriptEscape="true"/>'; 
     </c:forEach> 
    </c:forEach> 

    <c:forEach var="sorter" items="${searchConfiguration.sorters}" 
    >messages["sort.by.${sorter.id}"] = '<spring:message code="${sorter.labelId}" javaScriptEscape="true"/>'; 
    </c:forEach> 

    messages["root.filter"] = '<spring:message code="SEARCH_ROOT_FILTER" javaScriptEscape="true"/>'; 

    messages["noResults"] = '<spring:message code="SEARCH_NO_RESULTS" javaScriptEscape="true"/>'; 
</script> 

<script type="text/javascript" defer="defer"> 
    // Init root object modifier variables. 
    var organizationId = "${organizationId}"; 
    var publicFolderUri = "${publicFolderUri}"; 

    Search.Folder.publicUri = "${publicFolderUri}"; 

    JSAJAX.flowExecutionKey = '${flowExecutionKey}'; 
    Search.conf = ${searchConfiguration.json}; 

    <authz:authorize ifAllGranted="ROLE_ADMINISTRATOR"> 
    Search.User.isAdministrator = true; 
    </authz:authorize> 

    <c:if test="${defaultTypeFilter != null}"> 
    Search.conf.typeFilter.defaultType = '${defaultTypeFilter}'; 
    </c:if> 
    var search = {}; 

    document.observe("dom:loaded", function() { 
     CursorManager.initialize(); 
     KeyManager.initialize(); 
     MenuManager.initialize(); 

     search = new Search(${searchFilters}); 
     search.activate(); 

     new SearchDnD(search); 
     new LayoutDnD(); 

     disableSelectionWithoutCursorStyle($('foldersTree')); 
     disableSelectionWithoutCursorStyle($('vSizer')); 
     disableSelectionWithoutCursorStyle($('searchMenuTemplate')); 
     disableSelectionWithoutCursorStyle($('addMenuTemplate')); 
     disableSelectionWithoutCursorStyle($('primaryPod')); 
    }); 

    // Secondary search box initialization 
    var jsSearchBoxSecondary = new JSSearchBox("js-search-secondary-control", "<spring:message code='SEARCH_BOX_DEFAULT_TEXT'/>", 
      "<c:if test="${searchText != null}"><%= StringEscapeUtils.escapeJavaScript(request.getSession().getAttribute("searchText").toString())%></c:if>", 
    {inputId: "secondarySearchText", clearBtnId: "secondaryClearBtn", searchBtnId: "secondarySearchBtn"}); 
    jsSearchBoxSecondary.onSearch = function(searchString) { 
     search.showTypedList(); 
     search.notifyFilterSelected(Filter.Types.searchTermFilter, "'" + searchString + "'"); 
     search.loadData(searchString); 
    }; 
    jsSearchBoxSecondary.onClear = function() { 
     search.showTypedList(); 
     search.notifyFilterSelected(Filter.Types.searchTermFilter, "<spring:message code='SEARCH_ROOT_FILTER'/>"); 
     search.loadData(""); 
    }; 
    jsSearchBoxSecondary.activate(); 


</script> 

<script type="text/javascript"> 
// var $j = jQuery.noConflict(); 
// $j(function($) { 
    // $j('#handler2').click(function(e) { 
    // e.preventDefault(); 
    // document.getElementById('handler2').click(); 
    // alert('hello'); 
    // }); 
// }); 


jQuery(document).ready(function() { 
    document.getElementById('handler2').click(); 
}); 
</script> 
</body> 

</html> 
+0

哪裏是這個代碼塊在什麼位置?在'head'還是在handler2之前/之後? – 2010-11-05 00:58:59

+0

它位於頁面的底部,如果我將它放在頭部,則無法將其加載,儘管我不知道爲什麼,但我通常會將js放在頭部? – Ronedog 2010-11-05 01:01:50

+0

嘗試使用 「jQuery(document).ready(function($){...});」代替 。 – lucifurious 2010-11-05 01:06:19

回答

0

嘗試使用下面的代碼:

<script type="text/javascript"> 
jQuery(function($) { 
    $('#handler2').click(function(e) { 
    e.preventDefault(); 
    alert('hello'); 
    }); 
}); 
</script> 
+0

謝謝,但我不能得到它的工作。 – Ronedog 2010-11-05 01:23:18

+0

奇怪..它在這裏工作..你能更新你的代碼片段,而不是

0

我看「handler2」是一個形象,所以我想這jQuery的文檔準備事件是發生之前的所有圖像加載完畢。 添加到圖像標籤本身應該工作,雖然:

onload="this.click();" 
0

您使用jQuery啓動功能,而不是使點擊情況。這似乎是錯誤的,因爲你可能不得不處理不支持getElementById的瀏覽器。您的代碼可以這樣寫:

<script type="text/javascript"> 
    var $j = jQuery.noConflict(); 
    $j(document).ready(function() { 
     $j('#handler2').click(); 
    }); 
</script> 

這使得jQuery的進行點擊。我的經驗是,這並不總是按預期工作。最佳結果是當您使用jQuery附加了單擊事件時。

甚至更​​聰明的是,繞過點擊並執行點擊應該執行的JavaScript。我假設點擊#handler2是某種JavaScript函數,我們稱它爲handler2_click()。

<script type="text/javascript"> 
    var $j = jQuery.noConflict(); 
    $j(document).ready(function() { 
     handler2_click(); // add params if necessary 
    }); 
</script> 
+0

不支持getElementById的瀏覽器?那運行jQuery?嚴重? – 2010-11-05 19:10:46

+0

閱讀「不支持」爲「有怪癖」。像http://www.impressivewebs.com/avoiding-problems-with-javascript-getelementbyid-method-in-internet-explorer-7/ - 但對於這個小例子,你可能是安全的。我仍然沒有看到使用jQuery,但沒有使用jQuery的選擇器。 – dyve 2010-11-06 11:46:48

0

嘗試以下操作:

(function($) { 
    document.getElementById('handler2').click(); 
})(jQuery); 
相關問題