Click here to Skip to main content
15,896,063 members
Articles / Web Development / HTML

Beginner Guide to Page and Script Debugging with Chrome

Rate me:
Please Sign up or sign in to vote.
4.95/5 (81 votes)
27 Nov 2011CPOL18 min read 1.3M   1.4K   129  
A beginner introduction to the features of the Chrome Debugger
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Chrome Debugging Example 2</title>
    <script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>
    <script type="text/javascript">

        var autoupdate = true;
        var updateInterval = 1000;
        var counter = 0;

        //Function contains deliberate mistake to demonstrate error in console
        function incrementCounter()
        {
            $('#counter').html(counter);

            for (var x=0; x<100;x++)
            {
                if (x == 0) {
                    //Console log message
                    console.log("Internal Loop Counter at 0");
                }
                
                if (x == 50)  {
                    //Console warning message statement
                    console.warn("Extenal Counter Incrementing");
                    counter++;
                }

                if (x == 99) {
                    console.log("Internal Loop Counter at 99");
                }

            }


            if (autoupdate) {
                setTimeout(function () { incrementCounter() }, updateInterval);
            }
            else {
                //Flag a console Error message
                console.error("Auto Update Stopped!");
            }
        }
    </script>
</head>
<body>
<h2>Test Page - Example 2</h2>
<hr />
<h3>Simple counter:</h3>
Counter value is: <div id="counter"><script type="text/javascript">incrementCounter();</script></div>
<hr />
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer
Scotland Scotland
I have been working in the Oil & Gas Industry for over 30 years now.

Core Discipline is Instrumentation and Control Systems.

Completed Bsc Honours Degree (B29 in Computing) with the Open University in 2012.

Currently, Offshore Installation Manager in the Al Shaheen oil field, which is located off the coast of Qatar. Prior to this, 25 years of North Sea Oil & Gas experience.

Comments and Discussions