Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道这个问题可能比这里通常问的更开放,但我想知道从网页收集所有链接然后将这些值放入 javascript 对象的最佳方法是什么。请原谅我,因为我不精通 javascript。
那些无疑会激怒我的人应该知道我已经“完成了我的功课”。
在家工作
var links = document.getElementsByTagName('a');
...返回链接元素。或者,如果您想要实际的网址,请添加以下内容:
links = Array.prototype.map.call(links, function(el) {return el.href;});