2013-05-16 70 views
0

我的瀏覽器與除IE以外的瀏覽器有問題。代碼如下。 以下是Master Page中的Div標籤代碼。與加載器的跨瀏覽器兼容性

<div id="pnlPopup" class="PrProgress" style="display: none;"> 
     <div id="innerPopup" class="PrContainer"> 
      <div class="PrHeader"> 
       Loading, please wait...</div> 
      <div class="PrBody"> 
       <img src="Images/activity.gif" alt=" "/> 
      </div> 
     </div> 
    </div> 
在母版

JavaScript函數如下

$(document).ready(function() { 

      Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);   
      Sys.Application.add_load(applicationLoadHandler); 
      Sys.Application.add_unload(applicationUnloadHandler); 
      Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler); 
      Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequestHandler); 
     }); 

我的CSS如下

<style> 
    .PrProgress 
{ 
    display: block; 
    position: absolute; 
    padding: 2px 3px; 
} 
.PrContainer 
{ 
    border: solid 1px #808080; 
    border-width: 1px 0px; 
} 
.PrHeader 
{ 
    background: url('Images/sprite.png') repeat-x 0px 0px; 
    border-color: #808080 #808080 #ccc; 
    border-style: solid; 
    border-width: 0px 1px 1px; 
    padding: 0px 10px; 
    color: #000000; 
    font-size: 9pt; 
    font-weight: bold; 
    line-height: 1.9; 
    white-space:nowrap; 
    font-family: arial,helvetica,clean,sans-serif; 
} 
.PrBody 
{ width: 220px; 
    height: 19px; 
    background-color: #f2f2f2; 
    border-color: #808080; 
    border-style: solid; 
    border-width: 0px 1px; 
    padding: 10px; 
} 
    </style> 

繼Hedaer標籤

<script src="js/jquery-1.8.3.js" type="text/javascript"></script> 
<script src="js/pgbScript.js" type="text/javascript"></script> 

添加腳本以下是pgbScript.js代碼

function applicationLoadHandler() { 
    /// <summary>Raised after all scripts have been loaded and the objects in the application have been created and initialized.</summary> 
}; 
function applicationUnloadHandler() { 
    mainForm.CleanUp(); 
    mainForm = null; 
    Sys.Application.dispose(); 
}; 
function beginRequestHandler() { 
    /// <summary>Raised after an asynchronous postback is finished and control has been returned to the browser.</summary> 
    mainForm.StartUpdating(); 
}; 
function endRequestHandler() { 
    /// <summary>Raised before processing of an asynchronous postback starts and the postback request is sent to the server.</summary> 
    // Set status bar text if any was passed through the hidden field on the form 
    mainForm.EndUpdating() 
}; 
var mainForm = 
{ 
    pnlPopup : "pnlPopup", 
    innerPopup : "innerPopup", 
    updating : false 
}; 
mainForm.StartUpdating = function() { 
    mainForm.updating = true; 
    mainForm.AttachPopup(); 
    mainForm.onUpdating(); 
}; 
mainForm.EndUpdating = function() { 
    mainForm.updating = false; 
    mainForm.DetachPopup(); 
    mainForm.onUpdated(); 
}; 
mainForm.onUpdating = function(){ 
    if(mainForm.updating) { 
     var pnlPopup = $get(this.pnlPopup); 
     pnlPopup.style.display = '';   
     var docBounds = mainForm.GetClientBounds(); 
     var pnlPopupBounds = Sys.UI.DomElement.getBounds(pnlPopup); 
//  var x = docBounds.x + Math.round(docBounds.width/2) - Math.round(pnlPopupBounds.width/2); 
//  var y = docBounds.y + Math.round(docBounds.height/2) - Math.round(pnlPopupBounds.height/2);  
     var x = docBounds.x + Math.round(docBounds.width/2) - pnlPopupBounds.width; 
     var y = docBounds.y + Math.round(docBounds.height/2) - pnlPopupBounds.height; 
     Sys.UI.DomElement.setLocation(pnlPopup, x, y); 
     //if(Sys.Browser.agent == Sys.Browser.InternetExplorer) { 
      if(!pnlPopup.iFrame) { 
       var iFrame = document.createElement("IFRAME"); 
       iFrame.scrolling= "no"; 
       iFrame.src = "nothing.txt"; 
       iFrame.frameBorder = 0; 
       iFrame.style.display = "none"; 
       iFrame.style.position = "absolute"; 
       iFrame.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"; 
       iFrame.style.zIndex = 1; 
       pnlPopup.parentNode.insertBefore(iFrame, pnlPopup); 
       pnlPopup.iFrame = iFrame; 
      } 
      pnlPopup.iFrame.style.width = docBounds.width + "px"; 
      pnlPopup.iFrame.style.height = docBounds.height + "px"; 
      pnlPopup.iFrame.style.left = docBounds.x + "px"; 
      pnlPopup.iFrame.style.top = docBounds.y + "px"; 
      pnlPopup.iFrame.style.display = "block";  
     //} 
    }   
} 
mainForm.onUpdated = function() { 
    // get the update progress div 
    var pnlPopup = $get(this.pnlPopup); 
    // make it invisible 
    pnlPopup.style.display = 'none'; 
    if(pnlPopup.iFrame) { 
     pnlPopup.iFrame.style.display = "none"; 
    } 
}; 
mainForm.AttachPopup = function() { 
    /// <summary> 
    /// Attach the event handlers for the popup 
    /// </summary> 
    this._scrollHandler = Function.createDelegate(this, this.onUpdating); 
    this._resizeHandler = Function.createDelegate(this, this.onUpdating);  
    $addHandler(window, 'resize', this._resizeHandler); 
    $addHandler(window, 'scroll', this._scrollHandler); 
    this._windowHandlersAttached = true; 
}; 
mainForm.DetachPopup = function() { 
    /// <summary> 
    /// Detach the event handlers for the popup 
    /// </summary> 
    if (this._windowHandlersAttached) { 
     if (this._scrollHandler) { 
      $removeHandler(window, 'scroll', this._scrollHandler); 
     } 
     if (this._resizeHandler) { 
      $removeHandler(window, 'resize', this._resizeHandler); 
     } 
     this._scrollHandler = null; 
     this._resizeHandler = null; 
     this._windowHandlersAttached = false; 
    } 
}; 
mainForm.CleanUp = function() { 
    /// <summary> 
    /// CleanUp all resources held by mainForm object 
    /// </summary> 
    this.DetachPopup(); 
    var pnlPopup = $get(this.pnlPopup); 
    if(pnlPopup && pnlPopup.iFrame) { 
     pnlPopup.parentNode.removeChild(pnlPopup.iFrame); 
     pnlPopup.iFrame = null; 
    } 
    this._scrollHandler = null; 
    this._resizeHandler = null; 
    this.pnlPopup = null; 
    this.innerPopup = null; 
    this.updating = null; 
}; 
mainForm.GetClientBounds = function() { 
    /// <summary> 
    /// Gets the width and height of the browser client window (excluding scrollbars) 
    /// </summary> 
    /// <returns type="Sys.UI.Bounds"> 
    /// Browser's client width and height 
    /// </returns> 
    var clientWidth; 
    var clientHeight; 
    switch(Sys.Browser.agent) { 
     case Sys.Browser.InternetExplorer: 
      clientWidth = document.documentElement.clientWidth; 
      clientHeight = document.documentElement.clientHeight; 
      break; 
     case Sys.Browser.Safari: 
      clientWidth = window.innerWidth; 
      clientHeight = window.innerHeight; 
      break; 
     case Sys.Browser.Opera: 
      clientWidth = Math.min(window.innerWidth, document.body.clientWidth); 
      clientHeight = Math.min(window.innerHeight, document.body.clientHeight); 
      break; 
     default: // Sys.Browser.Firefox, etc. 
      clientWidth = Math.min(window.innerWidth, document.documentElement.clientWidth); 
      clientHeight = Math.min(window.innerHeight, document.documentElement.clientHeight); 
      break; 
    } 
    var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); 
    var scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); 
    return new Sys.UI.Bounds(scrollLeft, scrollTop, clientWidth, clientHeight); 
}; 
if(typeof(Sys) !== "undefined")Sys.Application.notifyScriptLoaded(); 

加載程序在IE中正常工作。但是,無論何時我在其他瀏覽器中瀏覽時出現錯誤爲 找不到資源。本地系統中的。 當我在生產服務器託管相同的代碼。 1)首先它會顯示加載程序 2)下一個404,錯誤頁面無法找到 3)幾秒鐘後,我會得到頁面請求。

請讓我知道如何避免資源無法找到。404,頁面無法找到錯誤在請求的中間。

下面是從生產服務器錯誤

服務器錯誤

404 - 文件或目錄未找到。 您正在查找的資源可能已被刪除,名稱已更改或暫時不可用。

以下是從本地系統中的錯誤,從我的應用程序中「/行使【期權」應用

服務器錯誤。

無法找到該資源。

說明:HTTP 404.您正在查找的資源(或其某個依賴項)可能已被刪除,名稱已更改或暫時不可用。請檢查以下網址並確保它拼寫正確。

請求的URL:/ExecutionSystem/nothing.txt

版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.1

+0

網頁選項卡在Chrome控制檯中說了什麼? – mplungjan

+0

謝謝,問題編輯瞭解更多信息。 – Hussain

回答

0

嘗試給一個更具體的SRC即:

iFrame.src = "~/nothing.txt"; 

,因爲Internet Explorer有時解決代碼中的一些小錯誤,其他瀏覽器沒有。