I'm trying to debug some javascript in IE 11 and I'm not able to force it to stop on a breakpoint.
debugger; line works fine (stops debugger in that line), same file without a debugger; line but with a breakpoint set in the same place does nothing (function works fine, but debugger does not stop on a breakpoint).
Chrome's and Firefox's debuggers stop on breakpoints in the same places.
Any thoughts what could be the cause of this behavior?
Hamlet, in the comments to OP question, gave the correct answer.
Uncheck the following option:
Internet Options > Advanced > Disable Script Debugging (Internet Explorer)
Related
How do I tell Firefox not to stop if it sees a debugger keyword?
I need to avoid a continuous debugger loop in case the website uses debugging protection generating debugger statements on the fly using timers.
Here is an example. In case you open the debugging console the script will throw tons of debugger statements, which will block you from normal debugging work.
An example website is http://www.avito.ru - the biggest classified site in Russia. Open it and then open the debugger console and it will be immediately stop at the debugger keyword in generated script.
(function(x/**/) {
(function(f){
(function a(){
try {
function b(i) {
if(
(''+(i/i)).length !== 1 ||
i % 20 === 0
) {
(function(){}).constructor('debugger')();
} else {
debugger;
}
b(++i);
}
b(0);
} catch(e) {
f.setTimeout(a, x)
}
})()
})(document.body.appendChild(document.createElement('frame')).contentWindow);
});
In the current version of Firefox at writing this answer (ver 63.0.3), in the Developer Tools, the Debugger section, there's an icon with the tooltip "Skip all pausing" or "Deactivate breakpoints". When enabled it seems to disable stopping at any debugger instruction.
Obviously the page tries to avoid people from debugging their JavaScript code with that construct.
Debugging in Firebug
Firebug allows to set disabled breakpoints on the debugger statements. Because the page generates a variable call stack depth, you'll need to set those disabled breakpoints for all of them to be able to debug the JavaScript properly. Unfortunately, Firebug seems to be buggy when it comes to set those breakpoints.
Furthermore, Firebug doesn't have an option to ignore all debugger statements.
So, if you don't need to debug JavaScript but only HTML, CSS, network requests, etc., you can simply disable the Script panel to avoid these annoying debugger halts. To do so, right-click the Script tab and click on Enable within the opening menu.
Note: Because Firebug development is discontinued, it's useless to file an enhancement request for it.
Debugging in Firefox DevTools
Unfortunately, the Firefox DevTools currently don't allow to avoid halting on debugger statements. So you have to wait until bug 1300934 (which mentions the same website as an example), bug 925269 and/or issue 828 are fixed.
Furthermore there is no way to disable the Debugger panel completely, which is filed as bug 1247198.
if you use Greasemonkey you can rewrite setTimeout/setInterval function to disable the script
unsafeWindow.setTimeout = function () {};
Chrome
in chrome you can edit the breakpoint and put a condition that is always false, it won't hit the debugger anymore
another option is to use "never pause here"
Firefox
for firefox, you can blackbox the script that you don't want to be hit by the breakpoint. for me it causes to hang the firefox. but when you restart the browser. then it's okay,
If you want to stop debugging without losing your breakpoints, then you need to disable breakpoints, not only to deactivate. Click right above the list of breakpoints and select Disable breakpoints. Then even if you refresh the page all breakpoints remain disabled. Tested with Firefox 101.0.1 on Ubuntu.
Is there any way to find out which JavaScript functions are called when a page is loaded?
One way is to use alert but if a file is too big ( in my case 5000+ lines ), it would be too difficult to use alert.
I want to find out is there anything in FireBug or Developer Tools that shows the order in which functions are called
Thanks
By the way, thanks to the person who gave negative comment
The Simple Solutions(tedious for you if you have 5000+ line codes) To Your Queries is
Debbuging
There are many way you can debug Your Javascript code
A)The Chrome DevTools include a number of useful tools to help make debugging JavaScript less painful.|
The Sources panel lets you debug your JavaScript code. It provides a graphical interface to the V8 debugger. Follow the steps below to explore the Sources panel:
Open a site on chrome
Open the DevTools window.
If it is not already selected, select Sources.
B)You can use FireBug Chrome tool But i Beleive Chroe Debugger is handy
but Choose Opera For Optimum result
path
Internet Explorer 8 (Developer Tools - F12). Anything else is second rate in Internet Explorer land
Firefox and Firebug. Hit F12 to display.
Safari (Show Menu Bar, Preferences -> Advanced -> Show Develop menu bar)
Google Chrome JavaScript Console (F12 or (Ctrl + Shift + J)).
Mostly the same browser as Safari, but Safari is better IMHO.
Opera (Tools -> Advanced -> Developer Tools)
use window.onload is perfect to your request
window.onload = function(){
alert("the page is loaded!!!");
};
it was tested onload=function vs window.onload=function
window.onload // works in all tested browsers
onload // works in all tested browsers, faster than window.onload
so it can't fail... use it, for me is the best way
Live CODE
I'm finishing up my website. Noticed I have some scripting issues in IE7 and IE8.
Using IETester (any better alternative btw?) IE9's debug tools I can test my website for different IE versions.
Updated Example:
I use JQuery and some 3th party htc files for IE css hacks.
"Line 87" is just a html line so that's not where the error occurs.
The IE Developer Tools (built into IE8+) has a JS debugger that will break on errors.
Hit F12 to open it, select the Script tab, then click the Start Debugging button.
This might sound crazy but is there a debugger out there which automatically breaks on the first line of executed code ?
Sample : suppose I have debug mode on and I click on a button. Now the intelligent debugger should automatically set the breakpoint on the first line inside the .click({}) function.
This way it is very easy to see the starting point and very easy to backtrack.
There must surely be something.
Thanks
Most debuggers in the browser allow you to insert the keyword
debugger;
into your code which will cause a break to occur at that point in the execution.
Chrome with CTRL+SHIFT+J. ;) You can put breakpoints there. I think it also works under FF. Also new versions of IE have JavaScript debuggers (don't remember the shortcut though).
F12 in most browser opens the debugger.
Chrome, Safari, IE have this by default, and for FF there is the Firebug add on.
Also you can debug from visual studio, select debug from the menu --> Attach to process and then select the interter explorer process. But You should enable the script debuging in Internet Explorer first.
I have some code that I thought I had written so that it would play nice on IE. But apparently it does not. I use IE8 for my testing and get quite frustrated with the built-in debugging 'tool'. I found that firebug has a javascript tool that debugs for IE but I have to click it for every page, wait for it to load and then test my script. Is there a way to make IE ALWAYS load the firebug .js file? I tried searching for way to set up a custom header file for my IE installation but was unsuccessful.
Is there another tool out there that would be better/easier to use? Another way to test scripts for IE compatibility?
IE7 and 8 provided the IE developer toolbar. This is similar to firebug for DOM inspection, script debugging and style tracing.
Edit:
For IE 8, the toolbar is already packaged with the browser:
The Developer Toolbar is not compatible with Internet Explorer 8. Please use the developer tools included with Internet Explorer 8. Press F12 or click the 'Developer Tools' entry in the Tools menu to begin using the tool. Click here for more information on IE8 Developer Tools.
You can also use Visual Studio and attach to the process in question, then just debug in VS. Pretty good debugging tools, and lets you debug IE6 as well.
Try my log4javascript, which is a logging library that works in every major browser, including IE 5 and later.