AJAX和相对路径范围 [英] AJAX and Relative Path Scope

查看:144
本文介绍了AJAX和相对路径范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Facebox(适用于jQuery)中的漂亮AJAX功能对包含SWF的页面进行Lightbox处理.麻烦的是,这些路径现在相对于主索引页面而不是相对于包含闪存页面的目录有效.这是目录的细分:

I'm trying to lightbox a page containing a SWF via the nifty AJAX feature in Facebox (for jQuery). The trouble is that the paths now work relative to the main index page, not the directory that houses the flash page. Here's a directory breakdown:

./
  -index.html(加载项目/projectName/index.html)
   + js/
      + jquery/
        -facebox.js
         -jquery.js
     + swfobject/
        -swfobject.js
   +项目
      + projectName
         -index.html(当以JS的相对路径单独查看时可以工作)
     + swf/

./
  - index.html (loads projects/projectName/index.html)
  + js/
      + jquery/
          - facebox.js
          - jquery.js
      + swfobject/
          - swfobject.js
  + projects
      + projectName
          - index.html (works when viewed by itself with relative paths to JS)
      + swf/

有人可以告诉我是否有某种方法可以通过jQuery(或实际上是任何Javascript)保留相对路径的范围?

Could anyone tell me if there's some way of preserving the scope of relative paths via jQuery (or any Javascript really)?

谢谢!

推荐答案

您不想以自己的方式使用相对路径,它们会以备份文件夹树的方式工作.尝试使用以Web根开头的路径,然后沿文件夹树向下移动.所以代替这个:

You don't want to use relative paths the way that you are, which work their way back up the folder tree. Try using paths that begin at the Web root, and instead work their way down the folder tree. So instead of this:

../../images/image.gif

或者这个:

./images/image.gif

您应该尝试以下操作:

/images/image.gif

这篇关于AJAX和相对路径范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆