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

Published
2022-08-08
浏览次数 :  177

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”

  • 标签1
  • 标签1
  • 标签1
Top