ChrisGr Posted December 6, 2006 Share Posted December 6, 2006 i am totaly new in javascript and i would like to find where the errors are in my code. is there a tool or some hints to help me? i want to do this because i have embeded in my html and php code some javascript and it gives me two errors. as a result the page does not play as it should. IE points the errors but i cannot find them because the lines it gives are incorect and .... ??? iam new in this. Thank you in advance. Quote Link to comment Share on other sites More sharing options...
obsidian Posted December 6, 2006 Share Posted December 6, 2006 Very good questions. In the few years I've been dealing with Javascript, I have not found an [i]easy[/i] way to debug. With PHP, your line numbers and all are actually printed to the screen, along with the actual errors, but as you say, with Javascript, IE [b]attempts[/b] to calculate the line number that it occurs on, but it is always in relationship to the actual rendered HTML, so if you're using PHP to generate your page, it can be nigh impossible to track down the precise location of the error that way.The best tool by far that I have found is the Javascript console equipped within the [url=https://addons.mozilla.org/firefox/60/]Web Developer extension[/url] for firefox. This gives very nice, detailed descriptions that aren't nearly as cryptic as those from IE. In addition, once you've traced down the [b]location[/b] of your error, some well places javascript alert()s showing the values of variables in question can be invaluable to debugging your code.I hope this helps some. Quote Link to comment Share on other sites More sharing options...
ChrisGr Posted December 6, 2006 Author Share Posted December 6, 2006 Thank you very much!!! I am now trying to discover the truth behind those lines of code using the javaScript console, although its not easy, it is a very good start. I love firefox! Quote Link to comment Share on other sites More sharing options...
fenway Posted December 16, 2006 Share Posted December 16, 2006 JS line numbers usually refer to the last line that it could process, which also means that unless it's one of those "null is null or not a object" errors, it's usually one line above. But then with separete runtimes, you'll always get line 1. Quote Link to comment Share on other sites More sharing options...
alpine Posted December 16, 2006 Share Posted December 16, 2006 The FireBug for Firefox - makes ie's errormessages seem like a joke (and it is)https://addons.mozilla.org/firefox/1843/ Quote Link to comment Share on other sites More sharing options...
fenway Posted December 16, 2006 Share Posted December 16, 2006 Not really fair to compare an extension to core functionality... I'm sure someone could write a similar plugin for IE. Quote Link to comment Share on other sites More sharing options...
alpine Posted December 25, 2006 Share Posted December 25, 2006 yeah, that might be...But IE's default javascript validator screams error in the down left corner (!) without doing any good explanation about the real problem at all. So it is (almost) useless for the developer, and the average visitor don't know what that yellow warning means at all anyways. In my sense it a waste exept that when it's not there its assumed that whatever you made is working in IE. It boils down to the fact that you need it just to check that your javascript is running ok in IE, but if it screams you cannot be sure to figure out where the problem is based on the information provided. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 26, 2006 Share Posted December 26, 2006 Maybe... the visitor should never see any JS errors ever, IE or otherwise; and the developer should be smart enough to track down the errors without a complex validation plug-in. Quote Link to comment Share on other sites More sharing options...
alpine Posted December 26, 2006 Share Posted December 26, 2006 [quote]the visitor should never see any JS errors ever[/quote]True - still far from reality[quote]and the developer should be smart enough to track down the errors without a complex validation plug-in[/quote]I guess that can be claimed, but we all use different tools one way or the other. One can scratch head for 30 minutes just to find a simple but "invisible" typo or use tools to find it and fix it in less than one. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 27, 2006 Share Posted December 27, 2006 [quote author=alpine link=topic=117567.msg491707#msg491707 date=1167139465][quote]the visitor should never see any JS errors ever[/quote]True - still far from reality[quote]and the developer should be smart enough to track down the errors without a complex validation plug-in[/quote]I guess that can be claimed, but we all use different tools one way or the other. One can scratch head for 30 minutes just to find a simple but "invisible" typo or use tools to find it and fix it in less than one.[/quote]Supressing errors isn't hard to do in a production environment; and yes, tools make it very easy not to learn how to do anything. Quote Link to comment Share on other sites More sharing options...
alpine Posted December 27, 2006 Share Posted December 27, 2006 [quote author=fenway link=topic=117567.msg492187#msg492187 date=1167242952]and yes, tools make it very easy not to learn how to do anything.[/quote]depends on what tools you use and how you use them. This became a silly and irrellevant discussion, we both know that!As a crafts-man i know to appreciate the value of tools, that is the fact whatever proffession you are in. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 28, 2006 Share Posted December 28, 2006 Perhaps... but I'll leave you with this thought: consider JS a hammer, and the "bug" to be a bent nail -- you don't need to call in the FBI to figure out what happened. Quote Link to comment Share on other sites More sharing options...
alpine Posted December 28, 2006 Share Posted December 28, 2006 That's a silly thought anyhow!If you stand with a modern car that wont start, what would you do ? Start checking each and every component manually and exchanging suspisious parts one by one until it eventually starts OR plug on the diagnostic reader to narrow down the problem or even find exactly what causes it? If you are doing it as an amateur home in your own shed i would say that the first one is most often the case, but when you are doing it for a living OR have the instrument available and know how to use it - the instrument is the solution, anything else would be insane. But it still doesn't make you an idiot, and you still learn by pattern what's most commonly the fault on the different carbrands from the symtoms that you have previously experienced and fixed.You have several degrees of using tools, the very one you have in front of you while reading this is a tool. Without it you would't be reding any of this... you can make a fire to cook coffee or you can make it using the coffe machine instead - really is up to you. If your house goes totally dark you can start exchanging lightbulbs OR find the voltmeter (it's a tool) to see if you infact have power in your fusebox first - really is up to you. Where would the world be without tools ? We sure as hell wouldn't be sitting here typing.By guessing, i figure you must be turning off all error reporting and notices while running php applications too ? Because that's the exact same thing as not using for instance the firebug extention for javascript. It's nothing but an error reporting and notice tool. You might call me and others using it for idiots, i don't. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 30, 2006 Share Posted December 30, 2006 This argument/conversation/discussion is going down a slippery slope, so I'm going to quit before it gets ugly. Suffice it to say that there's nothing wrong with using a diagnostics reader to figure out what wrong, provided that you know how each component works, and it's just a time saver. 99% of the time, looking at the code for another 10 seconds will reveal the problem outright. Quote Link to comment Share on other sites More sharing options...
alpine Posted December 31, 2006 Share Posted December 31, 2006 A good discussion is nothing but healthy, this one however emerged from its proposions. No hard feelings! Quote Link to comment Share on other sites More sharing options...
fenway Posted December 31, 2006 Share Posted December 31, 2006 [quote author=alpine link=topic=117567.msg493966#msg493966 date=1167523773]A good discussion is nothing but healthy, this one however emerged from its proposions. No hard feelings![/quote]True enough... it's more a matter of personal preference. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.