7 Replies Latest reply: Apr 18, 2012 6:58 AM by pziecina RSS

    Testing JavaScript in Live View

    Shan-Dysigns Community Member

      When I test simple JavaScript in Live View, I sometimes inadvertently get caught in a loop (using an alert for example). Other than ending the exe process, is there a way I can escape out of such loops? For example, when testing JavaScript in Firefox, you are given the option to stop the alerts.

        • 1. Re: Testing JavaScript in Live View
          SnakEyez02 CommunityMVP

          Can you post an example script that is causing a loop?  I don't know what to say at this point, but if it's a certain code that is causing this issue it could be something the developers need to look into fix in which case you would need to post a bug report.

           

          https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform

           

          Also is this, Mac/Win or both? and what version of the OS?

          • 2. Re: Testing JavaScript in Live View
            Shan-Dysigns Community Member

            This has nothing to do with a particular script, OS, or platform.It could be any script which puts me into a loop. There are times in which I might (in haste) have an "if" statement change the value of a var, and that "if" statment initiates whatever code I have inside it which keeps calling a function over and over. Just imagine getting caught in a loop - how you get there doesn't matter. My question is, how to escape out of it if I happen to test something in Live View. This doesn't happen because I don't know JavaScript, it happens because I work too fast some times and get caught in a loop while trying different code.

            • 3. Re: Testing JavaScript in Live View
              SnakEyez02 CommunityMVP

              This has nothing to do with a particular script, OS, or platform.

               

              Ok so it happens that you are thrown into a loop on both the Mac and Windows versions of Dreamweaver in Live View.

               

              It could be any script which puts me into a loop.

              If there's code we can test, that would be better.  But at the heart of the issue you seem to be missing my point.  I don't know if DW has the ability to debug or stop the script from executing or if it's a particular loop or code execution that is causing the DW lockup, thus the loop you are unable to escape.  This might be better handled as a bug report/feature request that I pointed you to so that the developers can examine your issue and maybe separate the Live View from DW (eg: sandbox it) so that it can be force shut down without forcing DW to quit.

              • 4. Re: Testing JavaScript in Live View
                Shan-Dysigns Community Member

                Note: doing this will catch you in an infinite loop - only test if you know how to end the dreamweaver.exe process and make sure you have any open data saved - copy/paste this into Dreamweaver and save it as a page (.htm, .php, whatever). Click Live View, then click the red box. This is not any particular code, but just something simple I created to show my issue. Like I said before, for whatever reason I find myself in an infinite loop while testing in Live View, I can't escape out of the code executing. Maybe I just need to slow down when testing, but this still brings up an issue that might need to be addressed. You really should be able to look at the code and know how the loop works (if you are weary about getting caught in a loop) - I can't imagine this would tax your CPU, but test this at your own risk.

                 

                <!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>

                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

                <title>Untitled Document</title>

                <style type="text/css">

                    .box {

                        width: 100px;

                        height: 100px;

                        background: red;

                        padding: 10px;

                        text-align: center;

                        cursor: pointer;

                    }

                </style>

                <script type="text/javascript">

                var a = true;

                function whatever() {

                    alert("looping");

                    if    (a) {

                        whatever();   

                    }

                }

                </script>

                </head>

                 

                <body>

                <div class="box" onclick="whatever()">click me</div>

                </body>

                </html>

                • 5. Re: Testing JavaScript in Live View
                  Shan-Dysigns Community Member

                  I guess I should add my main issue is just escaping out of "alert" messages I use when testing. I guess I should learn about Firebug and use the console.log.

                  • 6. Re: Testing JavaScript in Live View
                    Shan-Dysigns Community Member

                    So no ideas from anyone?

                    • 7. Re: Testing JavaScript in Live View
                      pziecina Community Member

                      Hi

                       

                      If you end up in a loop in live view, deselect live view and correct your code.

                       

                      PZ