The code arranges the elements of the document's <a> tags into an array and then prints out each of the href values in the array. Next, it opens the URL contained in the first element of the array, in a new window.

    var urls = document.getElementsByTagName('a');
    for (url in urls) {
      console.log ( urls[url].href );[url].href, '_blank');
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.