2011-11-15 33 views
0

處理我在我的母版驗證碼:的JavaScript運行時錯誤甚至沒有與代碼

<script type="text/javascript"> 
function silentErrorHandler() { return true; } 
    window.onerror = silentErrorHandler; 
alert("handled"); 
</script> 

但我仍然得到這個錯誤: 錯誤:無法獲得屬性「scrollLeft」的價值:對象null或undefined

如何完全禁止這些錯誤而不必在ie中設置禁用腳本調試?

我會修正這個錯誤,但是我已經花了太長時間看這個問題並沒有一個人曾這樣評價我的其他職位: https://stackoverflow.com/questions/7915208/jscript-runtime-error-on-callback-using-updatepanel

<%@ Page Title="" Language="VB" MasterPageFile="~/WinPlan.master" AutoEventWireup="false" 
    CodeFile="Scheduler.aspx.vb" Inherits="Scheduler" %> 

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %> 
<%@ Register Assembly="DayPilot" Namespace="DayPilot.Web.Ui" TagPrefix="DayPilot" %> 
<asp:Content ID="PageHeadContent" ContentPlaceHolderID="page_header_content" runat="Server"> 
    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server" EnableViewState="true"> 
    </asp:ScriptManagerProxy> 
    <asp:UpdatePanel ID="upnlSearchBar" runat="server"> 
     <ContentTemplate> 
      <div class="searchBar"> 
       <table id="userSearchBar"> 
        <tr> 
         <td align="left"> 
          <asp:Label ID="Label1" runat="server" Text="From: " Font-Bold="true" Width="50"></asp:Label> 
         </td> 
         <td align="left"> 
          <asp:TextBox ID="txtFromDate" runat="server" Width="80"></asp:TextBox> 
          <asp:ImageButton ID="imgCalendarFrom" runat="server" Width="18" ImageUrl="~/Images/SmallCalendar.gif" /> 
          <act:CalendarExtender ID="CalendarExtenderFrom" runat="server" Format="dd/MM/yyyy" 
           Enabled="true" PopupButtonID="imgCalendarFrom" TargetControlID="txtFromDate"> 
          </act:CalendarExtender> 
         </td> 
         <td align="left"> 
          <asp:Label ID="l3" Text="" runat="server" Width="20"></asp:Label> 
         </td> 
         <td align="left"> 
          <asp:Label ID="Label2" runat="server" Text="To: " Font-Bold="true" Width="30"></asp:Label> 
         </td> 
         <td align="left"> 
          <asp:TextBox ID="txtToDate" runat="server" Width="80"></asp:TextBox> 
          <asp:ImageButton ID="imgCalendarTo" runat="server" Width="18" ImageUrl="~/Images/SmallCalendar.gif" /> 
          <act:CalendarExtender ID="CalendarExtenderTo" runat="server" Format="dd/MM/yyyy" 
           Enabled="true" PopupButtonID="imgCalendarTo" TargetControlID="txtToDate"> 
          </act:CalendarExtender> 
         </td> 
         <td align="left"> 
          <asp:Label ID="l4" Text="" runat="server" Width="20"></asp:Label> 
         </td> 
         <td align="left"> 
          <asp:Button ID="btnSearchSchedules" runat="server" Text="Search" Width="60px" BorderStyle="None" 
           Height="22px" ForeColor="White" CssClass="btn" /> 
         </td> 
         <td align="left"> 
          <asp:Label ID="L5" Text="" runat="server" Width="20"></asp:Label> 
         </td> 
         <td valign="middle"> 
          <asp:Button ID="btnUsers" runat="server" Text="Users" Width="60px" BorderStyle="None" 
           Height="22px" ForeColor="White" CssClass="btn" OnClientClick="editUsers();" /> 
         </td> 
         <td align="left" valign="middle"> 
          <asp:Label ID="L6" Text="" runat="server" Width="20"></asp:Label> 
         </td> 
         <td valign="bottom"> 
          <asp:CheckBox ID="chkBusinessHours" runat="server" Text=" Show Business Hours Only" 
           Height="22px" BorderColor="Transparent" Font-Bold="true" ForeColor="Black" AutoPostBack="true" /> 
         </td> 
         <td width="40px"> 
         </td> 
        </tr> 
       </table> 
       <table id="adminSearchBar" runat="server"> 
       </table> 
      </div> 
     </ContentTemplate> 
    </asp:UpdatePanel> 
</asp:Content> 
<asp:Content ID="MainContent" ContentPlaceHolderID="main_content" runat="Server"> 
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always"> 
     <ContentTemplate> 
      <div id="dp"> 
       <DayPilot:DayPilotScheduler ID="DayPilotScheduler1" runat="server" CellGroupBy="Day" 
        DataStartField="StartDate" DataEndField="EndDate" ScrollLabelsVisible="true" 
        DataTextField="CustomerName" DataValueField="Workcard" DataResourceField="EmployeeCode" 
        CellDuration="60" CellWidth="50" ViewType="Resources" Width="100%" Heigth="100%" 
        RowMinHeight="30" RowHeaderWidth="150" HeigthSpec="Max" HeaderFontSize="10pt" 
        HeaderWidth="150px" HeaderHeight="20" EventFontSize="8pt" EventMoveHandling="CallBack" 
        TimeFormat="Clock12Hours" DurationBarVisible="false" BusinessBeginsHour="8" BusinessEndsHour="18" 
        ClientObjectName="dps" EventClickHandling="JavaScript" EventClickJavaScript="editEvent(e.value());" 
        OnCommand="DayPilotScheduler1_Command" EventCorners="Regular" RowMarginBottom="5" 
        ContextMenuID="DayPilotContextMenu" TreeIndent="15" TreeImageNoChildren="images/tree_nochildren.png" 
        TreeImageCollapse="images/tree_collapse.png" TreeImageExpand="images/tree_expand.png" 
        CssClassPrefix="scheduler_" EventBackColor="" EventFontFamily="" HourNameBackColor="" 
        HourFontFamily="" HourFontSize="" HeaderFontFamily="" HourBorderColor="" BackColor="#ececfe" 
        NonBusinessBackColor="White" CellBorderColor="Silver" OnBeforeResHeaderRender="DayPilotScheduler1_BeforeResHeaderRender" 
        AutoRefreshEnabled="true" AutoRefreshInterval="10" HeightSpec="Max" Height="630"> 
       </DayPilot:DayPilotScheduler> 
       <DayPilot:DayPilotMenu ID="DayPilotContextMenu" runat="server" CssClassPrefix="menu_"> 
        <DayPilot:MenuItem Action="Javascript" JavaScript="redirect()" Command="Details" 
         Text="View Job Creator" /> 
       </DayPilot:DayPilotMenu> 
       <asp:UpdateProgress DynamicLayout="false" DisplayAfter="1" ID="UpdateProgress2" runat="server"> 
        <ProgressTemplate> 
         <div class="Progress"> 
          <img src="./images/ajax-loader.gif" /> 
          Loading ... 
         </div> 
        </ProgressTemplate> 
       </asp:UpdateProgress> 
       <act:AlwaysVisibleControlExtender ID="AlwaysVisible" runat="server" TargetControlID="UpdateProgress2" 
        HorizontalSide="Center" VerticalSide="Middle" HorizontalOffset="0"> 
       </act:AlwaysVisibleControlExtender> 
      </div> 
     </ContentTemplate> 
    </asp:UpdatePanel> 
</asp:Content> 
+0

您從未在其他問題上發佈任何代碼(如所請求),因此沒有人能提供幫助。這些錯誤可能是由各種各樣的事情造成的。 – Pointy

+0

可能重複的[window.onerror不起作用](http://stackoverflow.com/questions/1915812/window-onerror-does-not-work) –

回答

0

從微軟文檔:

The onerror event fires for run-time errors, but not for compilation errors. In addition, error dialog boxes raised by script debuggers are not suppressed by returning true. To turn off script debuggers, disable script debugging in Internet Explorer by choosing Internet Options from the Tools menu. Click the Advanced tab and select the appropriate check box(es).

好的一面是,大多數普通的IE用戶(或者其他任何瀏覽器的用戶)都沒有啓用腳本調試。

+0

我需要能夠抑制錯誤,而不改變設置在ie 。錯誤似乎來自daypilot控件,當它被我需要的updatepanel包圍時。當我在jscript中檢查控件屬性時,scrolltop屬性設置爲0. – Cla

+0

嗯,我對這些控件一無所知。如果你不能有錯誤彈出窗口,正確的解決方案是解決這些錯誤。也許IE8/9開發人員工具可以幫助找到問題。 – Pointy

0

似乎JavaScript代碼是由服務器端生成的,因爲您的ASP.net代碼不包含任何JavaScript代碼。因此,很難判斷哪裏出了問題。

+0

是的,它是生成服務器端。當我通過js查看daypilot調度器屬性時,我發現scrollLeft和scrollTop屬性被設置爲0,即使錯誤表示它們爲null或未定義... im lost – Cla

相關問題