访问haha.html时,在haha.html的javascript中得到haha.html名称? window.location ?? document.title ??...... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script>var str=location.href;alert(str.substr(str.lastIndexOf("/")+1))</script> 同意 qiushuiwuhen(秋水无恨) alert(document.location.lastIndexOf.substr(document.location.lastIndexOf("/")+1)); alert(location.href.replace(/(.+)\//,"")) 可是haha.html?me="tom"&you="lucy"只想得到haha.html alert(location.pathname.replace(/(.+)\//,"")) 对于本地路径无效果.... 得到的结果"/G:/Documents%20and%20Settings/***/Local%20Settings/Temp/nonA.htm"能否写个通用的? 本地 / Web 都能获取...?另外.. 对于 URL .. 还得考虑 %20 ... 毕竟文件名是允许有空格的. 不知这样是不是算完事了?... 秋水大大再改进改进...<SCRIPT LANGUAGE="JavaScript">var path=location.pathname;alert((path.search(/\\/)!=-1)?path.replace(/(.+)\\/,"").replace(/(%20)/ig," "):path.replace(/(.+)\//,"").replace(/(%20)/ig," "));</SCRIPT> <script>alert(location.pathname.replace(/(.+)[\\/]/,""))</script> jQuery模板和数据绑定多出个Jquery对象怎么处理 extjs 中的tabpanel获得每一个tab的id值 谁有优酷播放器代码 json 问题 帮忙 求一正则 如何让cookie在整个根目录下都有效 急求:JavaScript如何将file上传到指定文件下,谢谢 左侧菜单向左移动 关于在弹出窗口中给父窗口的列表框增加项目遇到的问题? 怎样动态增加页面内容 现在要在输入完密码以后,按回车就登陆,有办法吗? 如何屏蔽F11?
var str=location.href;
alert(str.substr(str.lastIndexOf("/")+1))
</script>
haha.html?me="tom"&you="lucy"
只想得到haha.html
得到的结果"/G:/Documents%20and%20Settings/***/Local%20Settings/Temp/nonA.htm"能否写个通用的? 本地 / Web 都能获取...?
另外.. 对于 URL .. 还得考虑 %20 ... 毕竟文件名是允许有空格的.
var path=location.pathname;
alert((path.search(/\\/)!=-1)?path.replace(/(.+)\\/,"").replace(/(%20)/ig," "):path.replace(/(.+)\//,"").replace(/(%20)/ig," "));
</SCRIPT>
alert(location.pathname.replace(/(.+)[\\/]/,""))
</script>