Go Premium for a chance to win a PS4. Enter to Win


prototype.js: $F(foo) = "element has no properties" -- but which element?

Posted on 2006-06-16
Medium Priority
Last Modified: 2010-08-05
I'm getting an "element has no properties" on line 1276 of prototype.js, which is almost certainly a result of a call I'm making in the $F('fieldname') syntax.  I know what usually causes this-- misspellings of 'fieldname', or neglecting the quotes around it if it's a string literal.  Generally an easy fix.

Thing is, I've just connected many, many untested functions with many, many instances of $F('whatever').  Looking through them is excrutiating, and breaking apart the functions to test them individually is not a desirable solution.  Is there a way to toss in some error-handling or event-logging that'll give me a better idea about what attempted element is failing?
Question by:Rakafkaven
  • 4

Author Comment

ID: 16924357
I just tried one thing-- inserting this line right above 1276:

$(temporaryfield).value = element.id;

This means that when the error hits,temporaryfield holds the id of the last element that was successfully parsed, which does narrow it down somewhat.  Still not a great solution.

Author Comment

ID: 16924372
Changing that line to:

$(temporaryfield).value = $(temporaryfield).value + "," + element.id;

...gives me a full log of successful parses, which should let me track down the culprit.  But if there's a way to return the line number or attempted-element name or any other more graceful approach, I'll be glad to award points for it.

Author Comment

ID: 16924628
Hey, mozilla has a built-in debugger.  Fancy that.  A little RSI with the "Step Into", and there I see where I tried to pass an entire array to my $F(whatever), rather than a single array element.  That helps some.

Author Comment

ID: 16924688
Well, I don't usually answer my own questions THAT quickly.  So... uh... tell me something interesting about debugging.  Seems a shame to let perfectly good points go to waste.
LVL 63

Accepted Solution

Zvonko earned 2000 total points
ID: 16926580
My first step in such situations is to disable the onLoad handlers by commenting them out //
Then I look for simple syntax errors. Most runtime errors are rooted in tricky syntax errors which are overloaded at starting some undefined functions whose definition lacks on syntax follow up errors.
When I get that far I spot some simple alerts(1), alert(2) at spots outside of any function or statement block. If the alerts do not occur in the order I expect, then I know that interpreter is scanning my source in some other way then I see it. Most again because of missing closing or opening curly braces. When the alerts then come in desirable order, then I know at least we see the same functions and then first I start debug function, most with alerts and seldom with debugger.


Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question