Uncaught TypeError: is not a function in Chrome

Artex

So I'm writing a userscript for a website and I'm encountering this error Uncaught TypeError: is not a function It doesn't occur in Firefox, but does in Chrome. I've spent the last hour debugging with no success.

I've provided the relevant snippets below to reproduce the error in chrome. The script is supposed to find the button containing the text 'Download' and return the href.

function getSubmissionSource(){
  var controlBar = document.getElementsByClassName("button submission rounded");
  for (var button of controlBar) { //errors here
    var link = button.getElementsByTagName("a")[0];
    if (link !== undefined && link.textContent == "Download") {
      return link.href;
    }
  }
}
console.log(getSubmissionSource());
<div id="test"">
  <span class="button submission rounded">
    <a href="/view/18251152/" class="prev dotted">Older</a>
  </span>
  <span class="button submission rounded">
    <a href="">-Remove from Favorites</a>
  </span>
  <span class="button submission rounded">
    <a href="">Download</a>
  </span>
  <span class="button submission rounded">
    <a href="">Note user</a></span>
  <span class="button submission rounded">
    <a href="/view/18385008/">Newer</a>
    </span>
</div>

Rayon

You need to use for loop to iterate through nodelist

function getSubmissionSource(){
  var controlBar = document.getElementsByClassName("button submission rounded");
  for (var i=0,iLen=controlBar.length;i<iLen; i++) { //errors here
    var link = controlBar[i].getElementsByTagName("a")[0];
    if (link !== undefined && link.textContent == "Download") {
      return link.href;
    }
  }
}
console.log(getSubmissionSource());
<div id="test"">
  <span class="button submission rounded">
    <a href="/view/18251152/" class="prev dotted">Older</a>
  </span>
  <span class="button submission rounded">
    <a href="">-Remove from Favorites</a>
  </span>
  <span class="button submission rounded">
    <a href="">Download</a>
  </span>
  <span class="button submission rounded">
    <a href="">Note user</a></span>
  <span class="button submission rounded">
    <a href="/view/18385008/">Newer</a>
    </span>
</div>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Uncaught TypeError: $.post is not a function

From Dev

chrome.runtime.connectNative generates Uncaught TypeError: undefined is not a function

From Dev

Uncaught TypeError:Undefined is not a function

From Dev

Uncaught TypeError: Object function

From Dev

Uncaught TypeError: undefined is not a function

From Dev

Uncaught TypeError: number is not a function

From Dev

Uncaught TypeError: undefined is not a function

From Dev

Uncaught TypeError: undefined is not a function

From Dev

Uncaught TypeError: $(...).stellar is not a function

From Dev

Uncaught TypeError: $.growl is not a function

From Dev

uncaught typeerror $(...).swipe is not a function

From Dev

Uncaught TypeError: $(...).autocomplete is not a function

From Dev

Uncaught TypeError: $(...).draggable is not a function

From Dev

Uncaught TypeError: MyView is not a function

From Dev

Uncaught TypeError: $(...).ready is not a function

From Dev

Uncaught TypeError: response is not a function

From Dev

Uncaught TypeError: method is not a function

From Dev

Showing Uncaught TypeError: e.target.setCapture is not a function in chrome

From Dev

Uncaught TypeError: $(…).on is not a function

From Dev

Uncaught TypeError: #<Object> is not a function

From Dev

jQuery - Uncaught TypeError: $ is not a function

From Dev

Uncaught TypeError: $(...).velocity is not a function

From Dev

Uncaught TypeError: $(...).tokenfield is not a function

From Dev

Uncaught TypeError: lang is not a function

From Dev

Uncaught TypeError: $(this).search is not a function

From Dev

Uncaught TypeError on self calling function in CHROME

From Dev

Uncaught TypeError: undefined is not a function

From Dev

Uncaught TypeError: undefined is not a function Chrome not working

From Dev

Showing Uncaught TypeError: e.target.setCapture is not a function in chrome

Related Related

  1. 1

    Uncaught TypeError: $.post is not a function

  2. 2

    chrome.runtime.connectNative generates Uncaught TypeError: undefined is not a function

  3. 3

    Uncaught TypeError:Undefined is not a function

  4. 4

    Uncaught TypeError: Object function

  5. 5

    Uncaught TypeError: undefined is not a function

  6. 6

    Uncaught TypeError: number is not a function

  7. 7

    Uncaught TypeError: undefined is not a function

  8. 8

    Uncaught TypeError: undefined is not a function

  9. 9

    Uncaught TypeError: $(...).stellar is not a function

  10. 10

    Uncaught TypeError: $.growl is not a function

  11. 11

    uncaught typeerror $(...).swipe is not a function

  12. 12

    Uncaught TypeError: $(...).autocomplete is not a function

  13. 13

    Uncaught TypeError: $(...).draggable is not a function

  14. 14

    Uncaught TypeError: MyView is not a function

  15. 15

    Uncaught TypeError: $(...).ready is not a function

  16. 16

    Uncaught TypeError: response is not a function

  17. 17

    Uncaught TypeError: method is not a function

  18. 18

    Showing Uncaught TypeError: e.target.setCapture is not a function in chrome

  19. 19

    Uncaught TypeError: $(…).on is not a function

  20. 20

    Uncaught TypeError: #<Object> is not a function

  21. 21

    jQuery - Uncaught TypeError: $ is not a function

  22. 22

    Uncaught TypeError: $(...).velocity is not a function

  23. 23

    Uncaught TypeError: $(...).tokenfield is not a function

  24. 24

    Uncaught TypeError: lang is not a function

  25. 25

    Uncaught TypeError: $(this).search is not a function

  26. 26

    Uncaught TypeError on self calling function in CHROME

  27. 27

    Uncaught TypeError: undefined is not a function

  28. 28

    Uncaught TypeError: undefined is not a function Chrome not working

  29. 29

    Showing Uncaught TypeError: e.target.setCapture is not a function in chrome

HotTag

Archive