0

I'm trying to debug a JavaScript in Firefox's debugger, and it won't let me set any breakpoints, and all the step buttons (step into, step out) are grayed out. I also tried Firebug, and I have the exact same results - no breakpoints, step buttons grayed out. What gives? This is my first post here, and I apologize for my messy code here. Anywho, here's my code:

<?xml version - "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Page 452 - Exercise 11.7</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial scale=1.0">
    <script>
        function buttonClicked() {
            var article = ["the", "a", "one", "some", "any"];
            var noun = ["boy", "girl", "dog", "town", "car"];
            var verb = ["drove", "jumped", "ran", "walked", "skipped"];
            var preposition = ["to", "from", "over", "under", "on"];
            var story = "Once upon a time, ";
            var sentence = "";
            alert (sentence);
            var output = document.getElementById("textArea");
            output.value = "";

            for (var i=0; i<=3; i++){
                sentence += article[Math.floor(Math.random()*article.length)] + " ";
                alert(sentence.charAt(0));
                alert("Story is " + story);
        /*  if (charAt(sentence[0-3]) == ".") {
            sentence +=
        } */
        sentence += noun[Math.floor(Math.random()*noun.length)] + " ";
        sentence += verb[Math.floor(Math.random()*verb.length)] + " ";
        sentence += 
        preposition[Math.floor(Math.random()*preposition.length)] + " ";
        sentence += article[Math.floor(Math.random()*article.length)] + " ";
        sentence += noun[Math.floor(Math.random()*noun.length)] + ".  ";
        story += sentence;
        output.value = story;
        window.alert (sentence);
        window.alert (story);
            //  sentence ="";

        }
        story += "THE END";
         // output.value = sentence;
     }
    </script>
</head>
<body>
    <p>Click the button for a funny story!<br/>
        <input type="button" id="go" onclick="buttonClicked()"            value="Go!"/><br/></p>
        <textarea id="textArea" rows="10" cols="30"></textarea>

</body>
</html>
Sarjan Desai
  • 3,683
  • 2
  • 19
  • 32
  • The step buttons being greyed out makes sense -- if you haven't hit a breakpoint, there's nothing to step through. What exactly are you doing when you try to set the breakpoint, and what exactly happens? Can you set breakpoints on other sites? It should work by clicking the line numbers in the debugger panel. – Callahad Oct 15 '15 at 02:32
  • The thing is, I've added several breakpoints, but the buttons remain grayed out. I'm trying to learn how to use the Firefox debugger, using the video https://youtu.be/r1-96MgrfMo. – stupidmoron Oct 15 '15 at 03:29
  • Are you refreshing the page after you set the breakpoints? – Callahad Oct 15 '15 at 13:15

0 Answers0