用javascript更改所有的hrefs?

用javascript更改所有的hrefs?,javascript,href,Javascript,Href,如何在页面加载时使用自定义URL更改所有HREF 对不起,我只是不知道该怎么做。我真的不认识任何js 谢谢任何能帮助我的人。非常感谢。您可以使用: // Execute this when the document is ready. window.onload = function () { // Get all the `<a>` tags. var all_a = document.querySelectorAll("a"); // Loop through all

如何在页面加载时使用自定义URL更改所有HREF

对不起,我只是不知道该怎么做。我真的不认识任何js

谢谢任何能帮助我的人。非常感谢。

您可以使用:

// Execute this when the document is ready.
window.onload = function () {
  // Get all the `<a>` tags.
  var all_a = document.querySelectorAll("a");
  // Loop through all the `<a>` tags.
  for (i = 0; i < all_a.length; i++)
    // Change the `href`:
    all_a[i].setAttribute("href", "whatever_you_want");
}
//文档准备好后执行此操作。
window.onload=函数(){
//获取所有的``标记。
var all_a=document.queryselectoral(“a”);
//循环遍历所有的``标记。
对于(i=0;i
如果您什么都不知道,而且显然没有阅读,请务必阅读。此外,删除此问题。