In Chrome's console (Tools ยป Developer Tools) the script I'm debugging is showing up without linebreaks even though the actual file has them. This has happened to me before, but I can figure out if it's something with the spaces in the file or a setting in Chrome. But it's pretty impossible to debug something when every error comes up as being on line 1. I tried restarting Chrome but no dice. Any idea how to get it back to normal?
Open your file with Notepad or some other editor and save it again. It seems like you ran into the same problem as the one mentioned here.
http://196.23.168.153/support/forum/p/Chrome/thread?tid=0936a4d8f8b915b5&hl=en
If that doesn't work, use the pretty print button :-)
It sounds like the file has been minified. Do you know if it's run through any kind of build process before you're looking at it?
If not, I'm not sure exactly why that might be happening. There is a halfway decent workaround:
Open the script in the Scripts tab, and click the {} prettyprint button at the bottom to restore the formatting. It's kind of annoying to have to do that all the time, though.
Is there a public link we could see? I can imagine that there might be some line-ending issues if the file was created on one platform (Mac/Linux/Windows) and is being viewed on another. Haven't run into this one myself yet.
I had this problem and it was the EOL line endings. I changed them from Mac Classic (\n) to Windows Dos (\n\r).
Related
Possible to set a breakpoint for the code block of javascript like the screenshot below.
How can we use them? VS always ignores.
If Internet Explorer is set as the browser when debugging, Visual Studio is, in theory, able to stop at breakpoints set at client side script. To use the feature, you will need to make sure that "Disable script debugging" is checked in your IE Internet Options, Advanced tab.
However, I have found VS script debugging to be a bit flaky; the breakpoint is not always hit, especially with VS2010 or earlier. My personal experience is that it works best in VS2012 or later.
That being said, if you're using VS as the client-side script debugger and you find that your client-side breakpoints are not getting hit, it is best to insert a "debugger;" line prior to the line you would like to break at to ensure that it is picked up by the VS script debugger.
pennstatephil posted a link above that indeed provides more information on the subject: http://msdn.microsoft.com/en-us/library/7seh8d72.aspx
Edit: I'm not able to add comments, but in response to sb9's comment about why one would use IE, I find debugging in Visual Studio a lot more convenient when investigating script behavior before postbacks occur and server-side behaviors occurring immediately after postbacks. Also, sometimes the VS/IE combination will catch errors that Chrome and Firefox/Firebug reports with a nonsensical error message.
In Visual Studio 2017 there is an option to enable/disable script debugging
Just enable it and you should be good to go.
There are seemingly infinite possibilities to why this happens. I just solved this problem after hours of searching.
My particular issue is that my breakpoints were disabled immediately after my coworker enabled bundling (see description here). I had to go into our BundleConfig.cs file and comment out the line that said:
BundleTable.EnableOptimizations = true;
After I did that, they were hit. You'd want to add that line back in for deployments.
Another scenario for the inability of the debugger to stop at the break point is if one uses bundling.
To debug JavaScript files, we need to remove bundling.
I hope this will help someone.
Yes you can put the break-point on client side page in Visual studio
First Put the debugger in java-script code and run the page in browser
debugger
After that open your page in browser and view the inspect element you see the following view
After OSX 10.8.4 update, this small script stopped working
tell application "Adobe Photoshop CS6"
do javascript "alert('hello world')"
end tell
Can anyone confirm it's a change in AppleScript syntax introduced in last updated,
or I'm missing something?
Can your reproduce this script on OSX 10.8.4?
The exact error I get is:
Syntax error
Expected end of line but found identifier.
And JavaScript is highlighted.
I just struggled with a similar problem in Illustrator CC on 10.8.5 for a few hours.
I was running the script through a shell command in a .sublime-build file (Sublime Text 2).
Running the same basic script once from the official AppleScript Editor subsequently fixed it.
I still need to investigate why. If you have an idea, please comment.
I think the problem your experiencing is due to the fact that you have to specify a tab for applescript to run the JS code in. For example:
do JavaScript "alert('Hey');" in tab 1 of front window
If you don't specify which tab to run the javascript code in, it always throws the same 'identifier' error.
Hope this helps. (I've been frustrated by this one myself. It's easy to forget)
--Sorry, just realized you were talking about Illustrator. My mind immediately went to Safari's 'do javascript'.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How do you debug Javascript applications?
When there's a bug in my javascript .js file, no error is indicated, and the file just does not load.
Is there a fast way to debug something like this?
I have to temporarily delete half the file, test it, delete another half, test it, and so on until I isolate the problem.
How can I display the error when javascript loads the page?
Firebug.
You can see if the file isn't being retrieved in the Net tab.
You can debug it and even add breakpoints in the Script tab.
You can view any errors/warnings in the Console tab.
Try using the firebug pluggin for firefox.
You can put break point and use the step by step debug mode.
Realy helpfull.
Get a js debugger for your browser: firebug if you use firefox. Chrome & Safari have builtin inspectors that do the same thing. IE as usual is more awkward. You should also check your js at jslint.com, although it gives lots of warnings you can ignore.
For Firefox: use Firebug
For Chrome: use the console
For IE: you're screwed. (place alert()s throughout your code and narrow down between the one that was called and the one that was not)
While there are many of versions of IE, this answer applies to IE 7, which is still what the majority of large corporations and government agencies use. Sure, there are workarounds, especially if you have Visual Studio, but question did not specify a browser in the first place.
IE7 has no console, thus the users is screwed and must inject his/her JS with alert()s or use a third-party tool.
After an hour or two of heavy use on the site I'm developing, Firebug develops the following problems:
Breakpoints get glitchy -- it becomes difficult to add/remove breakpoints. Sometimes I click on a line multiple times, see nothing, move to the console tab and back, and then see my breakpoints again.
Console stops logging xhr's, or stops logging debug statements.
Script files become non-viewable.
I'm working with a javascript file which is quite large (over 10k lines). I don't think this is a memory leak issue with my own code. I'm refreshing the page all the time. Looks like an issue on the Firebug side. Is my logic sound? Is there anything I can do to get firebug to behave better? Or do I just need to restart firefox every hour?
Keep in mind Firefox while wonderful has always had many issues with handling memory. You should take a look at your task manager to see Firefox's memory footprint. Additionally I'd break up that JS file if you could into smaller chunks (for many reasons aside of this as well) to be better readable and work with the segments. Finally turn off plugins your not using or that may conflict with Friebug if your not using them.
I spent hours using Firebug without restart Firefox and never crashed, try a clean profile, install on it only Firebug and check if all works fine.
I use a separated development profile with Firebug and other dev oriented extensions installed.
How to configure a profile is described in many sites, on my wiki you find a brief description
i have similar problems! i think it is partially to do with the massive JS files. I just re-start firefox every once and a while. no big deal.
I'm looking for a way to have an interactive JIT debugger, preferably integrated with Firebug.
I got the idea from PHPEd, which has an "Immediate" debug tab where you can just type in PHP code and modify objects on the fly. This makes debugging a breeze as you can re-assign variables multiple times, re-execute functions, etc without leaving the program.
Here's what I think would be superb:
- set a breakpoint in Firebug
- arrive to breakpoint
- have an Execute JS tab where one could enter JS code, similar to what I described above
Does anything like this exist already?
TIA.
You can already do this in Firebug. Just get to a break point, then go to the "console" tab, and type your commands into the command line at the bottom (where there's the ">>>").
If I understand the question correctly, I think can do that already in firebug.
Set a breakpoint (or use the debugger
keyword)
Click the console tab
the bottom line allows you to enter a
javascript command.
if you need more space click the icon
that looks like an upside down v in
the bottom right part of the browser.
You might also like the JS execute extension.
Actually, Firebug can do this and it's only a matter of a little investigation on their website to find out how to do this best :) Good luck!
Agree with parents that Firebug is the best choice. Another option that requires a good deal of configuration would be Aptana. For folks using the Eclipse IDE, Aptana is a solid editor for Javascript work. The plus with Aptana is that it's tied more to a code editing environment.