2009-11-16 51 views
0

我在網站上使用LightBox v2.0.4與母版頁,並且出現load.gif和closelabel.gif圖像時出現問題。 在lightbox.js,每當我運行程序它給在這一行燈箱在主頁面中的promblem

fileLoadingImage:  
'images/loading.gif',  
fileBottomNavCloseImage: 'images/closelabel.gif', 

錯誤但是,如果運行與使用了母版頁上述申請的每一件事工作正常,沒有問題。 每當我們用Master頁面實現時,我們會得到一個javascript錯誤。 有沒有人得到這種類型的錯誤?你是如何解決它的?

任何幫助將是偉大的。

+0

什麼是錯誤信息? – Marco 2009-11-16 12:39:18

+0

看到這個問題:如何在Master Pages中使用JQuery? - http://stackoverflow.com/questions/292787/how-to-use-jquery-with-master-pages – Phaedrus 2009-11-16 14:35:55

回答

0

什麼是實際錯誤?沒有這個,我們不能沒有幫助。

作爲第一步,使用Firebug或類似的方式調試你的頁面 - 例如,這將顯示指定的圖像路徑是否無效(你將在網絡控制檯中獲得一個404)。

+0

我在lightbox.js腳本文件的這一行找不到錯誤提示圖像 LightboxOptions = Object。擴展({fileLoadingImage:'images/loading.gif',fileBottomNavCloseImage:'images/closelabel.gif', – happysmile 2009-11-16 18:00:54

0

肯定是路徑問題。

頁面是否在不同的目錄中使用主頁面,而這個目錄可能是工作的?

這適用於我。由於javascript是在代碼後面生成的,因此可以使用波浪符號來解析正確的路徑。

檢查http://www.zedesigns.com/Showroom.aspx看到它在行動。

protected void InsertLightbox() 
    { 
     if (!Page.ClientScript.IsClientScriptIncludeRegistered("jquery-latest.pack.js")) 
      Page.ClientScript.RegisterClientScriptInclude("jquery-latest.pack.js", "http://code.jquery.com/jquery-latest.pack.js"); 

     if (!Page.ClientScript.IsClientScriptIncludeRegistered("jquery.lightbox.js")) 
      Page.ClientScript.RegisterClientScriptInclude("jquery.lightbox.js", System.Web.VirtualPathUtility.ToAbsolute("~/js/jquery.lightbox.js")); 

     if (!Page.ClientScript.IsClientScriptBlockRegistered("lightbox")) 
     { 
      System.Text.StringBuilder sb = new System.Text.StringBuilder(); 
      sb.AppendLine("$(document).ready(function(){"); 
      sb.AppendFormat("$('.lightbox').lightbox({{fileLoadingImage:'{0}',fileBottomNavCloseImage:'{1}',fitToScreen:true}});", Page.ResolveClientUrl("~/images/lightbox/loading.gif"), Page.ResolveClientUrl("~/images/lightbox/closelabel.gif")); 
      sb.AppendLine("});"); 
      Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "lightbox", sb.ToString(), true); 
     } 

     Helpers.Page.AddStyleSheet(this, "~/styles/lightbox.css", "screen"); 
    }