javascript shows no breakline in debugger - javascript

When I upload to dreamhost my page, I can't debug it because javascript appears with no end of line, like this for example:
function fun(){ alert("1");alert("3");if($("#tbTitulo").val()==""){alert("1");return;}}
so it is practically impossible to debug. I tried on firefox and chrome with the same results. I don't know why this is happening. If you could give me some clue I'd really appreciate it.

You can prettify the code in Chrome Developer Tools. The button is the last one on the bottom row on the sources tab (it looks like a pair of curly brackets):
https://stackoverflow.com/a/6318092/1669279

First you have to Beautify, unpack or deobfuscate JavaScript and HTML, make JSON/JSONP readable, etc.
check here
http://jsbeautifier.org/
after that you can insert breakpoint to debug.

Related

How to Quickly Find Unused Part of the CSS and JS Codes in Chrome DevTools?

I am using Chrome DevTools to analyze the code coverage of a page https://www.datanumen.com/blogs/5-methods-remove-highlighting-shading-word-document/
I get the following result:
I notice that there are some CSS files that have 98.1% and 99.7% unused rate, so I want to figure out what part is actually used. But these files are rather large, for example, ssba.css is 4000+ lines, and I can only see red vertical lines beside, but cannot find the green ones to indicate the used part. And it is rather time-consuming to scroll down one by one for a 4000+ line file. So, is there an easy way to jump to the first used part, then go to the next used part, etc.? Or in other word, quickly find the used parts easily?
Chrome DevTools cannot actually edit your code for you, since it is located on a server (or in this case, your machine) which Chrome doesn't have access to. The best you can do is either automate it with an extension, script or other tool.

Are there any ways to show code hints for javascript automatically in Dreamweaver

I use Dreamweaver CS6 in Win7.
I know DW CS6 can show code hints for javascript by hitting ctrl + space in windows.
This time, I would like to know if there are any ways to show the code hints for javascript automatically by just typing some characters or marks without hitting the shortcut key or not.
I think it will reduce typing greatly.
Dreamweaver code hint doesn't smart, sometimes will show code hint automatically when you make newline,
you have to use shortcut to open it.

Add line break inside bookmarklet

I have a bookmarklet that allows me to wrap any function and insert a debugger statement before it is called.
It works fine, but since the bookmarklet is a single line debugger stops somewhere in the middle of a long string of code and I need to scroll to find the breakpoint.
How can I insert a new line character after the debugger statement so that when it's encountered the code in the console is split into two lines?
The \n and literal newline character copied from a textarea into the bookmarklet don't split lines in the debugger.
Generally, it is best to URL-encode a bookmarklet before storing in a bookmark. So you can have a multiline bookmarklet simply by encoding the newlines, as demonstrated by this: encodeURIComponent("alert('line1');\nalert('line2');")
That answers the question as you asked it, but I'm not sure if this is your real problem. If you provide example code I might be able to give further advice.
No, bookmarklets are always one-liners.
You can use the chrome debugger which has a "prettify code" option.
Another option would be not running it as a normal bookmarklet during debugging but injecting a script tag pointing to a properly formatted version of your script.

How do I see error messages for JavaScript/JQuery code in IE?

I am new to javascript and have been working overnight to see how I can fix this error on IE: Here's the question I asked here yesterday: How to fix this jquery function to work in IE?
After spending more than 20 hours I still can't find out why it wouldn't render parts of my page properly.
At the very least I thought I could find a way to get the errors so I can fix them or do a separate javascript file just for IE, but no luck.
How do I see error messages for my script?
I used F12 to see the developer console but no help there, it won't even tell me what's wrong.
I am using IE 8 and 9.
I know that there could be many things wrong with this and I appreciate your patience in advance for helping me out. Thanks!
You have invalid HTML including many invisible characters within the head section which is also blocking the W3C HTML Validator from getting past the first few errors.
When I copied your source code into my text editor, I found a bunch of invalid invisible characters. Did you cut/paste your JavaScript from someplace like a web-page? The invisibles only appear in front of your custom written scripts in the <head> and nowhere else. This could certainly explain a lot, including the validation error about a misplaced </head> tag. Go back to your editor and delete the indentations on every single line within the entire <head></head> section, then re-indent each line from scratch.
I also see an invalid closing tag, </label6>.
Remove the invisible characters, fix the invalid HTML, and see what IE does.
Moving forward, get yourself a powerful text editor that will allow you to see invisible characters so you can delete them and properly indent as needed. Otherwise, I recommend re-typing your code rather than cutting & pasting.
For JavaScript errors, the best is to see the 'Console' tab for records.
If IE's one isn't showing anything, maybe you could try using FireBug Lite, adding the following script after <head> (YES, put it as first thing, so it loads first than anything else).
<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script>
On side note, maybe isn't a JS problem and yes something about running code locally. IE has some policies that mostly block client-side code from running. (Remember those annoying ActiveX prompts?). Check Intranet configuration on Settings.

How to use fiddler to debug?

I have a webpage when it finished on the left bottom there's a warning says:Done, but with errors on the page. I double click it and it told me:
Line:628
Char:100
Error: Expected ')'
Code: 0
URL:.....
I knew Fiddler is a good tool to debug. I download it and try to debug. The line IE told me I just can't find anything that's missing ')'
Can someone tell me how to debug this?
IE may be interpreting line numbers differently than you expect. Firebug is probably a better tool for helping debug this type of problem.
Fiddler is good at capturing what goes across the stream. It's like comparing a hammer and a wrench. Each is the right tool for a specific job.
If using IE8, hit F12 to bring up the debugger. You can start debugging and have it show you exactly where your error is occurring.
The open ( is probably occurring several lines before the missing ).

Categories