Javascript获取当前url以及获取数组最后一个的写法

Published
August 8, 2022
浏览次数 :  2

var part = [];
  var url = window.location.href;
  part = (url.toString()).split('/');
  if (part[part.length - 1] == 'notification.php') {
    fetchNotification();
  }

扩展项:

window.location.protocol = “http:”
window.location.host = “css-tricks.com”
window.location.pathname = “/example/index.html”
window.location.search = “?s=flexbox”

Top