WEBINAR: On-demand webcast
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >
Use these to jump around or read it all
What You've Learned
Please Note! In later versions of MSIE and Navigator, you may not get the box above. I guess the programmers felt there was a better way.
If you are using MSIE, the error message will first appear as a triangular sign in the lower left hand corner. There will be an exclamation point in the triangle. There will also be some text proclaiming there are errors on the page. Click on that triangle to get the error message we'll discuss in this tutorial. OR! If you want to get the error message box each time without clicking, go to the Tools menu, choose Internet Options. In Internet Options, click on the Advanced tab and make sure the line that reads: "Display a notification about every script error" is checked.
Then again, depending on how your system was configured when you got it, you may already be getting the box. You'll also note on the error box that you'll have to click the "Details" button to see the text describing the error.
I don't understand the change either...but them's the breaks. Moooooving along...
The Error Message
Now, there are programs out there that will help you fix your errors, a process called "debugging," but I still prefer to do it by hand. It's actually easier than you think.
Fixing the Errors
The Error Line
document.write("text for the page"
) </SCRIPT> </BODY>
But why is the error on line 9? That's because you count from the top of the HTML document down, counting every line. Here's the document again, but this time with the lines counted for you.
(line 9)document.write("text for the page"
Notice that when you count the lines, you count all the lines, even the blank ones.
Once you're actually at the line that has an error, you need to decide what to do. More times than not, if it's a Syntax error, the line has been chopped off early (truncated), something is misspelled, or you have used double quotes where a single quotes should go (unbalanced quotes).
If the error is Run-Time, then the command the error message is pointing at is a command that doesn't logically follow in the sequence. For instance, you call for a button by using a command that actually calls for a text box.
Nothing gives me heartburn faster than running a script and getting multiple errors. All you can do is sit while a whole slew of gray error boxes pile up on your desktop. I used to think multiple boxes meant there were actually multiple errors. Not always so.
You see, the first error in the script may very well be creating all the other errors. So, fix the errors in sequence from the top of the HTML document to the bottom. Many times I've found a script that threw ~20 error boxes, but by fixing only the first error I solved all the problems.
So, fix the errors one at a time, from top to bottom. And each time you fix an error, run the script again. You might get 20 error messages, but only have to fix one or two.
Something's Not Defined
This is also very common. This is a Run-Time error that means that something in the script doesn't jibe quite right. The text, to the computer anyway, has come out of the clear blue sky. I always make sure the text wasn't created by jumping a line down too early. If that's not the case, I try erasing it. It can always be put back at another time. Typos occur. See if this isn't one of those typos. It happens more times than you'd believe.
There's not much more that can be said about error messages at this point. You now have enough knowledge to fix 99% of the problems that pop up. Just remember that getting error messages is actually a plus. If you didn't get them, then all you would have is a blank page with no suggestions about what the problem might be. They're quite helpful if you think about them in the right light.
What You Have Learned
Below there is a link to a page with a script. When you click on the link, the script will throw two errors. Your assignment is to fix the two errors so that the script runs. Now, you probably won't recognize some of the commands in this script, but that doesn't matter. The error boxes that appear will give you enough information to make this script run.
If the script runs correctly, the current date will display on the page. Again, each of these links will open a new window.
Hint: You may only get one error when you run it. The second error might then come after you fix the first.
What You've Learned