AJAX 和相对路径范围

发布于 2024-07-07 19:59:24 字数 761 浏览 15 评论 0原文

我正在尝试通过 Facebox 中漂亮的 AJAX 功能(针对 jQuery)对包含 SWF 的页面进行灯箱处理。 问题在于,这些路径现在是相对于主索引页工作的,而不是相对于包含闪存页面的目录。 这是目录细分:

./
  -index.html(加载projects/projectName/index.html)
+ js/
    +jquery/
        -facebox.js
        -jquery.js
    +swfobject/
        - swfobject.js
+ 项目
     +项目名称
        -index.html(使用 JS 的相对路径单独查看时有效)
      + swf/

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

谢谢!

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 (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/

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

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

淤浪 2024-07-14 19:59:25

您不想像现在这样使用相对路径,因为它们会沿着文件夹树的方式返回。 尝试使用从 Web 根开始的路径,然后沿着文件夹树向下移动。 因此,不要这样:

../../images/image.gif

或者这样:

./images/image.gif

您应该尝试这样:

/images /图像.gif

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

Or this:

./images/image.gif

You should try this:

/images/image.gif

不美如何 2024-07-14 19:59:25

我不确定我是否完全理解这个问题(你有源代码/网址示例吗)。

Base HREF 标签可以让您在 iFrame 中设置相对路径起始位置,并且您应该能够从那里使用相对路径。

I'm not sure I understand the question completly (do you have source code / url example).

The Base HREF tag can let you set the relative path start in your iFrame, and you should be able to use relative paths from there.

白馒头 2024-07-14 19:59:25

更多信息可能会有所帮助。 主 index.html 是重定向到 projectName 下的那个,还是在 FRAME/IFRAME 中打开它? 哪一个有 .facebox() 调用?

A bit more info might be helpful. Is the main index.html redirecting to the one under projectName, or opening it in a FRAME/IFRAME? Which one has the .facebox() call in it?

孤者何惧 2024-07-14 19:59:25

抱歉没有上传! 必须清理一些尚未展示的项目。

http://www.kevinsweeneydesign.com/help/

这里可以看到路径都是单独查看文件时正确(当我尝试对内容进行面框时,它会变得很奇怪):

http://www.kevinsweeneydesign.com/help/projects/propod/

Facebox 调用来自 ./help/index.html 文件。 它尝试在facebox调用中加载./help/projects/propod/index.html。 但是, ./help/projects/propod/index.html 文件使用位于 ./help/js/swfobject/ 中的 JS

更新:我尝试设置基本标签(将其设置为 ./projects/propod)...这有效,但仅适用于图像。 我仍在修改“base”参数来提供 SWF,但无济于事...当我查看 Firebug 中的对象标记时,就像链接到图片=/

Sorry for not uploading! Had to clear out some projects that can't be shown yet.

http://www.kevinsweeneydesign.com/help/

You can see here that the paths are all correct when viewing the file by itself (it just gets screwy when I try to facebox the content):

http://www.kevinsweeneydesign.com/help/projects/propod/

The facebox call is from the ./help/index.html file. It tries to load the ./help/projects/propod/index.html in the facebox call. However, ./help/projects/propod/index.html file uses JS that's located in ./help/js/swfobject/

Update: I tried setting the base tag (set it to ./projects/propod)...that worked, but only for images. I'm still tinkering with the 'base' parameter to give the SWF but to no avail...I don't see any "_ base_href" getting attached when I look at the object tag in Firebug like I did when linking to an image =/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文