js获取当前网址Url

js获取当前路径并截取

var str = window.location.href;// str = 'https://localhost:8080/mark'
var index = str .lastIndexOf(":");  

str  = str .substring(0,index + 1);

  console.log(str);//结果为:https://localhost:

 

posted on 2019-10-12 10:55  婧星  阅读(6380)  评论(0编辑  收藏  举报

导航