justuptime.com - monitor your servers & websites

locating errors in scripts... i.e. line "123"

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

They have: 140 posts

Joined: Nov 2003

O.k., this may be a stupid question but it is time I found out how to track down errors in scripts.

My question is: when an error appears on a page it usually says... error on line "xxx". How do you find line "xxx" ? other than counting down lines????

timjpriebe's picture
DeveloperModeratorSponsor

He has: 2,666 posts

Joined: Dec 2004

Use an editor that displays line numbers next to the lines.

For Windows, ScITE is one such editor.

teammatt3's picture
Moderator

He has: 1,902 posts

Joined: Sep 2003

Are you using notepad? Just hit ctrl g and type in the line number. Make sure word wrap is turned off, or it won't work.

Megan's picture
Administrator

She has: 10,288 posts

Joined: Jun 1999

You may also be able to use the web developer extension for whichever browser you are using, or change your default source viewer to something that shows line numbers. I've found this helpful when the generated source is different from the original source. Then you can use the toolbar extension to view the generated source and check for the right line number.

Your HTML editor may not show the line numbers by default - look for an option to turn them on. Most editors should have this option available.

He has: 339 posts

Joined: May 2007

Opera and Firefox have error consoles that display meaningful error messages caused by both JavaScript and CSS errors. Tools > Error Console in FF2; Tools > Advanced > Error Console in Opera.

IE does have a debugger, but I found it hard to use.

Did you know about Firebug?

Cordially, David
--
"Old web developers don't die, they degrade gracefully..."

They have: 140 posts

Joined: Nov 2003

thanks very much.