js获取url地址

来源:互联网 发布:php yii2框架教程 编辑:程序博客网 时间:2024/05/14 08:45

eg: http://write.blog.csdn.net/postedit?ref=toolbar  获取到http://write.blog.csdn.net

function getPath() {    var strFullPath = window.document.location.href;    var strPath = window.document.location.pathname;    var pos = strFullPath.indexOf(strPath);    var prePath = strFullPath.substring(0, pos);    return prePath;}

$(document).ready(function () {    alert(getPath());});


0 0
原创粉丝点击