Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    cub
    cub is offline
    New Coder
    Join Date
    Jan 2012
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts

    getElementsByTagName is not a function

    today looking through my logs (errors) and one that came up was
    Code:
    element.getElementsByTagName is not a function
    from the source

    Code:
     
    getByAttribute = function(element, strTagName, strAttributeName, strAttributeValue)
    {
          var arrElements = (strTagName == "*" && element.all)? element.all : element.getElementsByTagName(strTagName);
    Can anyone help me out here?
    thanks

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Can anyone help me out here?
    Please provide your rest of the code.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Clearly getElementsByTagName *is* a function, but it might not be valid for the kind of element you were trying to apply it to.

    DEBUG and tell us what kind of element you go the message for.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    cub
    cub is offline
    New Coder
    Join Date
    Jan 2012
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hi
    here it is ,
    https://www.squibblefeeds.com/applic...v=4.0.5b&c=142

    I thought it was better this way rather than filling up an entire page (line 705 or just ctrl+f it)

    Thanks all
    David

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Well, first of all, the code is really old.

    element.all was only needed by MSIE 4. (Maybe MSIE 5?) By the time MSIE 6 arrived, getElementsByTagName was there. (Along with getElementById, of course...that appeared in MSIE 5). And "all" was never needed by any other browser.

    But as to why you get an error on that code...

    Dunno. The only place you call it, you pass body for the element argument.

    And that should clearly work.

    I don't suppose you can show this in a working online page, instead of just as code?

    ***********

    I notice that when you call the function, your last argument is a regular expression.

    But the function is *clearly* expecting just a string for that last argument.

    Because it *builds* a regular expression based on the expected string.

    This whole thing seems pretty convoluted to me. You really need to find *ALL* the <option>s on a given HTML page so that you can remove them if they have values with a certain pattern?? Surely you know which <select>s might hold <option>s with this pattern and you could more efficiently apply the removal process to only them?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    cub (01-19-2012)

  • #6
    cub
    cub is offline
    New Coder
    Join Date
    Jan 2012
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hi
    Thaks for the reply, yeah it is abit, i'm planning to rebuild the whole site again this year, after all it was a prototype and that bit of code was the first done a while back.
    change after change without really reconfiguring the whole system has had it's toll on it

    Thanks for everything really appreciate it
    David
    Last edited by cub; 01-19-2012 at 11:29 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •