javascript:如何根据子目录包含文件

发布于 2024-09-13 19:28:29 字数 504 浏览 1 评论 0原文

我需要你的帮助。我需要根据当前子目录在模板上包含外部文件(菜单)。 对于即;我有两个子目录:

http://subdomain.domain.com/xx/index.html< /a>

http://subdomain.domain.com/yy/index.html

每个子目录都有自己的菜单文件。

如何在 JavaScript 上创建此条件脚本:

如果子目录是 xx,则包含 menu-xx.html

如果子目录是 yy,则包含 menu-yy.html

else include menu.html

感谢您的帮助

I need your help. I need to include external files (menu) on a template depending on the current sub directory.
For ie; I have two sub directories:

http://subdomain.domain.com/xx/index.html

http://subdomain.domain.com/yy/index.html

and each sub directory has own menu file.

How to create this conditional script on JavaScript:

if the sub directory is xx include menu-xx.html

if the sub directory is yy include menu-yy.html

else
include menu.html

Thanks for your help

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

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

发布评论

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

评论(1

小…楫夜泊 2024-09-20 19:28:29

等等...当做出这个决定时,您将进入这两个 html 页面之一?如果是这种情况,您将查找与当前文档相关的 html 文件 - 假设它位于该子目录中。

也就是说,如果我正确地阅读了这篇文章...

如果没有,那么您是否使用 window.location 进行了探索?

https://developer.mozilla.org/en/window.location

Wait... when this decision is being made you'll be in one of those two html pages? If thats the case you look for the html file thats relative to the current document - assuming its in that sub-directory.

That is if I'm reading this correctly...

If not, then you have you explored using window.location?

https://developer.mozilla.org/en/window.location

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