syracuse-singers / xmas

Syracuse Caroling
https://syracuse-singers.github.io/xmas/
0 stars 1 forks source link

Change JavaScript file opener in README #28

Closed tomkeays closed 4 years ago

tomkeays commented 4 years ago

The README file had a snippet of JavaScript that opened all links that were in a list in a new window.

<script type="text/javascript">
  var list = document.querySelector("ul"); 
  var links = list.getElementsByTagName("a"); 
  for (var i = 0; i < links.length; i++) { 
      links[i].setAttribute("target", "_blank"); 
  }
</script>

However, what I really wanted to do was open the PDF files in a new window. So, this:

<script type="text/javascript">
  var pdfs = document.querySelectorAll("a[href$='.pdf']"); 
  for (var i = 0; i < pdfs.length; i++) { 
      pdfs[i].setAttribute("target", "_blank"); 
  }
</script>