【发布时间】:2012-10-30 07:35:15
【问题描述】:
如果您在http://www.cnn.com/2012/11/09/opinion/brown-pakistan-malala/index.html 上,您可以让Jquery 获取index.html 吗?
或者如果您在http://www.washingtonpost.com/politics/decision2012/supreme-court-to-review-key-section-of-voting-rights-act/2012/11/09/dd249cd0-216d-11e2-8448-81b1ce7d6978_story.html 上返回dd249cd0-216d-11e2-8448-81b1ce7d6978_story.html?
对于非扩展定义的页面,例如当前的http://stackoverflow.com/questions/13317276/jquery-to-get-the-name-of-the-current-html-file,它是否可以返回“目录”结构中的最后一个“文件”,例如:jquery-to-get-the-name-of-the-current-html-file
【问题讨论】:
-
如果当前页面只是
http://stackoverflow.com/怎么办?你只想要“stackoverflow.com”吗? -
好澄清,是的,路径名的最后一个就是我要找的
-
我正在使用此代码 document.location.pathname.match(/[^\/]+$/)[0] 但是当我在我的基本链接中时,例如
http://stackoverflow.com/它正在抛出控制台出错,有什么方法可以验证吗?
标签: javascript jquery html