js url处理的问题 var url = "../aa/aa.html" 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 对了,补充下, //这样定义是可以实现的 var url="../aa/aa.html"; //我原意是获取当前url(有虚拟目录就取虚拟目录,无的话就得到原url) //如:http://127.0.0.1/aaa.html===>在这个页就得到http://127.0.0.1,若有虚拟目录:http://127.0.0.1/web/xxx.html,即得到http://127.0.0.1/web/ .net开发时候 可以用统一的函数来写路径例如:我们有个论坛地址www.bbs.ishangdu.comfunction string bbsUrl(){//处理返回地址}js调用这个函数var url=<%= bbsUrl%>你可以把bbsUrl写成全局的函数统一调用 没理解你到底要什么效果,是不是要得到当前文件所在的目录呢?<script>var url = document.location.href.substring(0,document.location.href.indexOf(window.document.location.pathname)) + document.location.pathname.substring(0,document.location.pathname.lastIndexOf("/")+1);alert(url);</script> 求助,页面不整齐,如何用js调整 JS如何调用名称含有特殊字符的对象? 谷歌地图难题,有谁会做的?? 求一个用js实现的树型下拉列表框 屏蔽层变灰 复杂表格怎样动态出 随机数问题,在线等,答对就结帖 小弟初学,想知道如何写并且取得一个Session变量用JavaScript? 请问怎么得到marquee现在的状态是否在滚动? JS 成员变量的问题 javascript处理大量数据导致IE未响应 100 分求助 iframe src
var url="../aa/aa.html";
//我原意是获取当前url(有虚拟目录就取虚拟目录,无的话就得到原url)
//如:http://127.0.0.1/aaa.html===>在这个页就得到http://127.0.0.1,若有虚拟目录:http://127.0.0.1/web/xxx.html,即得到http://127.0.0.1/web/
例如:我们有个论坛地址www.bbs.ishangdu.com
function string bbsUrl()
{
//处理返回地址
}
js调用这个函数
var url=<%= bbsUrl%>
你可以把bbsUrl写成全局的函数
统一调用
<script>
var url = document.location.href.substring(0,document.location.href.indexOf(window.document.location.pathname)) + document.location.pathname.substring(0,document.location.pathname.lastIndexOf("/")+1);alert(url);
</script>