开发者

javascript: how to include file depending on subdirectory

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 开发者_C百科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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜