2012-08-06 41 views
2

我在SharePoint開發中收到了javascript錯誤「Line上的無效參數:2 char:141544 in sp.ui.rte.js」。這似乎是來自谷歌在SharePoint js文件中的已知問題 - http://wss.boman.biz/Lists/Posts/Post.aspx?List=c0143750-7a4e-4df3-9dba-8a3651407969&ID=69 在分析影響後,我決定,而不是更改SharePoint 14配置單元中的js我想壓制錯誤消息只是此錯誤。我試圖做到以下幾點:針對特定情況在頁面上抑制JavaScript錯誤

ClientScriptManager cs = Page.ClientScript; 

      //Check to see if the startup script is already registered. 
      if (!cs.IsStartupScriptRegistered("Alert")) 
      { 
       StringBuilder cstext1 = new StringBuilder(); 

       cstext1.Append("<script type=text/javascript> window.onerror = function (msg, url, num) {return true;} </"); 
       cstext1.Append("script>"); 

       cs.RegisterStartupScript(this.GetType(), "Alert", cstext1.ToString()); 
      } 

的問題是,這將打壓頁面不只是那些sp.ui.rte.js上所有的JS錯誤。是否可以在URL上進行字符串搜索(http://SHAREPOINT/_layouts/sp.ui.rte.js?rev = uY%2BcHuH6ine5hasQwHX1cw%3D%3D - 其中站點之間唯一一致的值將是/ _layouts/sp.ui.rte.js?)只搜索並抑制這個確切的錯誤? 感謝您的幫助!

回答

1

使用try/catch阻止JS中的代碼。如果消息匹配你想忽略的東西,就什麼也不做。傳播一切。

如果你改變它來分析信息和傳播一切不匹配忽視的字符串,以及你的原件.onerror辦法將工作太。

+0

我寧願不更改任何在SharePoint JS如果可能的話,所以我決定不使用Try/Catch method.I試圖分析信息,但這是我的問題所在。我在一個線程中看到有人使用urlsearch,但我無法實現這一點。感謝您的意見! – Signpost 2012-08-06 12:29:17

1

到目前爲止,這一直是最成功的修復,我發現,目前使用:

function fixRTEBug() { 
    // This Fix for parentElement bug in RTE should survive Service Packs and CU's 
    function SubstituteRTERangeParentElement() { 
     var originalRTERangeParentElement = RTE.Range.prototype.parentElement; 
     RTE.Range.prototype.parentElement = function() { 
      try { 
       originalRTERangeParentElement(); 
      } catch (e) { } 
     } 
    } 
    SubstituteRTERangeParentElement(); 
} 

ExecuteOrDelayUntilScriptLoaded(fixRTEBug, "sp.ui.rte.js"); 
+0

當我嘗試,我得到一個錯誤'ExecuteOrDelayUntilScriptLoaded()'不定義,所以我儘量拖延與一個'的document.ready()',因爲他們在這裏說:http://sharepoint.stackexchange.com/questions/31387/error-running-executeordelayuntilscriptloaded?rq = 1但它仍不能抑制層次結構錯誤。我在這裏有更多的細節:http://sharepoint.stackexchange.com/questions/164012/hierarchyrequesterror-in-sp-ui-rte-js – bgmCoder 2015-12-05 16:15:11