2009-11-16 84 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"); 
    }