NH is right by suggesting you use an IDE as a solution. Though also Firebug provides the information you need.
1) the function named such and such is not defined > Such error messages come from the browser. Firebug just displays them. And if you think, they are wrong, then please post a concrete example, so we can sort that out. 2) there is no javascript on the page. What I think the messages really > mean is that Firebug isn't smart enough to figure out that 1) you've messed > up some syntax somewhere, with the result that your function is no longer > syntactically correct, or that 2) you've forgotten to put in, or have > accidentally removed/messed up, a <script type="text/javascript"></ > script> pair > That's right and that's also what the description below the message already says: *"If <script> tags have a "type" attribute, it should equal "text/javascript" or "application/javascript". Also scripts must be parsable (syntactically correct)." *** > > Firebug would help me locate the causes of these errors As you suspected later the *Console* panel<https://getfirebug.com/wiki/index.php/Console_Panel>helps you to find syntax errors. In case there are syntax errors in your scripts they'll be listed there with the line of code shown below the error message and you can display the exact line of the error by clicking the code sample or the source link at the right. It would be nice if Firebug included or integrated well with 1) pretty > print software Syntax highlighting of scripts can be enabled via the Firebug extension FireRainbow<https://getfirebug.com/wiki/index.php/Firebug_Extensions#FireRainbow>. And Firebug will have integrated syntax highlighting in the upcoming version. If you want to display minified code in some readable format, please have a look at the extension Javascript Deminifier<https://getfirebug.com/wiki/index.php/Firebug_Extensions#Javascript_Deminifier> . > and 2) version control software (though it may well be that I'd find the > learning curve for version control software daunting). > Note that Firebug is a debugging software. For this purpose you need an IDE like e.g. Eclipse <http://www.eclipse.org/>, though. I think there is functionality in Firebug for executing code and seeing the > changing contents of variables as it executes You may want to read about how the Command Line works<https://getfirebug.com/wiki/index.php/Command_Line>and also see the description of how to use the debugging features of Firebug<https://getfirebug.com/wiki/index.php/Script_Debugging> . but I'm not sure that I've seen a button for executing just the next line > of code. Of course there is. Firebug has three buttons allowing you to step through the code, *Step Into*, *Step Over* and *Step Out*. These are called execution control buttons<https://getfirebug.com/wiki/index.php/Script_Panel#Execution_Control_Buttons> . There doesn't seem to be help integrated into Firebug > Just press F1 while Firebug is focused and you'll get to a page with some useful links. Sebastian On Friday, May 31, 2013 7:52:03 AM UTC+2, Gal Steinitz wrote: > > Hi there, > > I definitely understand your frustration, JavaScript is different from > other languages in many ways, and the host (in this case - the browser, and > the DOM) is also a unique beast. However I do find that once you understand > the core principles of JavaScript itself, it is actually quite a simple, > pure, and very malleable and flexible language...And this last fact is what > can allow really bad javascript to be written, but also really great > javascript. > > If you haven't already, I would recommend reading "JavaScript: The Good > Parts" by Douglas Crockford (http://amzn.com/0596517742), and watch some > of his talks ( > http://www.youtube.com/watch?v=RO1Wnu-xKoY&list=PL7664379246A246CB). > > Also, I think well structured javascript is going to be significantly > easier to debug, and will potentially prevent those bugs in the first > place. I really like BackboneJS for the structure and patterns that it > brings to javascript. It is a really lightweight javascript framework and > provides a solid, software engineering approach to your javascript. > > From some of what you described, it sounds like you may be dealing with a > large file with a lot of javascript (a "god class" or a "god function") - > that is going to be hard for even the most experienced programmer to deal > with. If your code is modular, split into different files, functions and > classes it can help locate the source of errors. Also it sounds like the > context switching and/or closures may be causing you some confusion and may > be behind what you're describing as variables disappearing - I would look > into learning more about these JavaScript concepts. (But you'll get that > from the book I linked) > > Finally, if you really want to take your javascript development to another > level, switching to Test Driven Development can be very illuminating, and > can help with tracking down errors, or again preventing them. I would > research TDD in general and then a good javascript unit test framework, > such as Jasmine or QUnit. > > I know this response was very broad, but so was your original post. As a > follow up - try posting a short, specfic question - you'll probably get > good responses. > > Good luck!! > > Regards, > Gal > > > > On Wednesday, May 29, 2013 8:41:09 AM UTC-7, [email protected] wrote: >> >> I find debugging javascript frustrating, even with the benefit of >> Firebug. It is likely that I haven't yet learnt to get the full benefit of >> Firebug's features. >> >> A single wrong character can make complex code stop working altogether, >> with Firebug displaying error messages which are untrue - or true in a very >> narrow sense - such as messages that 1) the function named such and such is >> not defined or that 2) there is no javascript on the page. What I think the >> messages really mean is that Firebug isn't smart enough to figure out that >> 1) you've messed up some syntax somewhere, with the result that your >> function is no longer syntactically correct, or that 2) you've forgotten to >> put in, or have accidentally removed/messed up, a <script >> type="text/javascript"></script> pair (though, in that case, you're readily >> alerted to a problem when your javascript code shows up in the text on the >> webpage; maybe there are some more subtle errors which also generate the no >> javascript on page error(?)). When I say "Firebug isn't smart enough" I >> don't mean to imply that it really ought to be, as I acknowledge that >> making sense of code and trying to figure out a programmer's intention is >> non-trivial, but, ideally, Firebug would help me locate the causes of these >> errors. Messages claiming that functions don't exist or that the page >> contains no javascript, seem to me to be saying, in effect, "Your code has >> problems which are too hard for me to figure out. You're on your own!" >> >> I'm unsure whether the message about a function not being defined can >> have a cause outside of the function named as not being defined. I >> currently have a feeling that it can. I think I'm probably getting this >> error saying one function is not defined when the code I've just messed up >> is actually in another function and when I haven't actually made any change >> to the named function. >> >> At present I'm repeatedly getting that message (about a function not >> being defined) after making editing changes. What I usually do then is >> visually inspect the code, looking for syntax errors, including clicking >> after complexly nested {s and }s (which, in my editor (SuperEdi), results >> in { } pairs being displayed in bold). I often annotate close braces with >> comments noting the if or else clause which the close brace is closing. I'm >> not presently convinced that the Console tab in Firebug helps me with >> finding the syntax problem in the case of "function not defined" or "no >> javascript on page" errors, though I admit I am not thoroughly familiar >> with using the Console tab. I think it's the case that, sometimes at least, >> it is necessary to click twice on the Console tab to see the line(s) of >> code which is/are causing problems. There may be times when helpful >> information is there but I'm overlooking it. >> >> I try to format my code to show the structure of if ... else clauses. I >> try not to make a lot of changes before saving under a different version >> number and retesting the code because it's important to be able to remember >> what I've done recently for the frequent occasions when my code >> substantially or totally stops working because of a recent change. It would >> be nice if Firebug included or integrated well with 1) pretty print >> software and 2) version control software (though it may well be that I'd >> find the learning curve for version control software daunting). Short of >> integrating version control software, I wonder if Firebug could feasibly be >> improved so that it cached the immediately previous version of code and >> could highlight the differences between the current version and the >> immediately previous version to help the programmer locate the newly >> introduced error(s). >> >> I think there is functionality in Firebug for executing code and seeing >> the changing contents of variables as it executes but I haven't so far been >> able to use it really successfully. There's a video recorder style play >> button to resume a script after an error but I'm not sure that I've seen a >> button for executing just the next line of code. I sometimes succeed in >> setting Watches on variables but other times Firebug insists that a >> variable doesn't exist or isn't defined/declared - I don't recall which. I >> appreciate that, during the execution of code, variables can properly >> appear and disappear as they come into and go out of scope. It seems to me >> that Firebug sometimes tells me that particular variables don't exist and >> that they never appear in the Watch window with values, even though the >> code successfully executes using such variables. I guess I need to >> persevere and gain more experience. There doesn't seem to be help >> integrated into Firebug, though the getfirebug.com webpage includes >> useful links e.g. to Firebug Tips & >> Tricks<http://www.softwareishard.com/blog/firebug-tips/> >> . > > -- -- You received this message because you are subscribed to the Google Groups "Firebug" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at https://groups.google.com/forum/#!forum/firebug --- You received this message because you are subscribed to the Google Groups "Firebug" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
