【问题标题】:javascript: how to include file depending on subdirectoryjavascript:如何根据子目录包含文件
【发布时间】:2010-08-09 01:24:21
【问题描述】:

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

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

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

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

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

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

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

否则 包括 menu.html

感谢您的帮助

【问题讨论】:

    标签: javascript include subdirectory


    【解决方案1】:

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

    如果我没看错的话……

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

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

    【讨论】:

      猜你喜欢
      • 2016-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-13
      • 1970-01-01
      相关资源
      最近更新 更多