【www.gdgbn.com--js教程】

js获取url参数与路径方法

如: http://localhost:8083/uimcardprjfunction getrootpath(){    //获取当

前网址,
如: jsp教程">http://localhost:8083/uimcardprj/share/meun.jsp   
var curwwwpath=window.document.location.href;    //获取主机地址之后的目

录,如: uimcardprj/share/meun.jsp   
var pathname=window.document.location.pathname;   
var pos=curwwwpath.indexof(pathname);    //获取主机地址,

如: http://localhost:8083   
var localhostpaht=curwwwpath.substring(0,pos);    //获取带"/"的项目名,

如:/uimcardprj  
 var projectname=pathname.substring(0,pathname.substr(1).indexof("/")

+1);   
return(localhostpaht+projectname);}

js参数表

网页特效
location property result
location.hash #test
location.host localhost:1351
location.hostname localhost
location.href asp教程x/adsf">http://localhost:1351/website1/dir/default.aspx/adsf?

id=12#test
location.pathname /website1/dir/default.aspx/adsf
location.port 1351
location.protocol http:
location.search ?id=12

本文来源:http://www.gdgbn.com/wangyezhizuo/29361/