【发布时间】:2012-02-18 05:48:05
【问题描述】:
在我的函数中,用户输入像'./images/profile' 这样的路径,我需要检查页面的当前路径是否与他传递的路径相同。
IE。检查是否path == location.pathname。
如果location.pathname 是/scripts 并且输入的路径./../parent/scripts 其中parent 是脚本的父目录,则比较应该返回true,如果输入的路径是./../parent/images 则应该返回false 等。
那么 JS 中有什么方法可以比较两条路径吗?
【问题讨论】:
标签: javascript path location pathname