I am developing a web-application, and google-chrome started behaving weird. When I make change in a JavaScript file, after I hit refresh on the debugger - I still see the same code in the debugger, and the browser executes this old code. Why is google-chrome behaving like this and how can I solve this?
Open Developer Tools, by right clicking and choosing "Inspect Element" or Ctrl/Cmd + Shift + J
Click the Cog icon in the bottom right of that window.
Choose the General Tab
Tick "Disable cache"
This will disable Chrome from caching (locally storing) a copy of the js file
perhaps is a cache problem. try doing a cache refresh (ctrl-r, ctrl-f5). if you use cache.manifest file then you need to touch it in some way and double refresh your app for the changes to show.
Related
I'm making a Chrome Extension and need to view the HTML/CSS/JS of the popup.html.
I can't right click to inspect elements. Is there another way? I need to make sure CSS and JavaScript is being inserted correctly. How to debug a problem in that popup file?
Right click the extension's button, then 'Inspect Popup'
Inspect Popup has gone away with the latest build.
Here's how I debug Chrome Extension Popups.
Click your popup button to see the webpage (the popup window itself).
Right-click in the window and select Inspect element
The Chrome Debugger window comes up with the right context, but you've already missed your breakpoints and debugger statements.
HERE'S THE TRICK. Click on the Console part of the debugger and type: location.reload(true) and press enter.
Now your breakpoints are hit! Great way to reload changed scripts without revisiting the Extension page.
Perhaps another way may be to find the ID: for your application in chrome://chrome/extensions/
You can then load your popup in a regular window by
chrome-extension://id_of_your_application/popup.html
Exchange popup.html for the file you have specified in manifest.json under "default_popup" property.
Yes, 'Inspect Popup' on the extension icon, and apart from that - from extension manager you can also inspect your options page.
Try switching Auto-open DevTools for popups in the bottom right of DevTools Settings:
Another good way to inspect Javascript being part of the extension popup is adding special comments to the end of the script to be debugged:
// #sourceURL=popup.js
This is de-facto a directive for DevTools to include this specific file into Sources tab. From there you can inspect code, add breakpoints, output to console, etc. as usual.
I have some JavaScript that, I believe, is stuck in an infinite loop. I know I can just reload the page, but I have data in a form on the current page that I'd like to keep. The tab is completely unresponsive, so I can't just copy and paste everything and then reload. So is there any way to kill the javascript thread, but keep the DOM in Chrome?
You can open the developer console F12 and stop the script
Open chrome developer tools and go to the sources tab. On the right panel press "pause script execution".
looks like someone had the same problem
Cancel infinite loop execution in jsfiddle
Answer:
With the developer mode, go into resources and find your script and copy and paste it into a text document or a new window. If you can't find it in resources, do a search for a variable or line of code you used.
Is there anyway to prevent changes to web pages such as a live chat or a video feed? Im guessing its a javascript that times out the webpage and then exits it or prevents further entry.
I saw this question: Freeze screen in chrome debugger / DevTools panel for popover inspection?
What I did was I inspected the element, then went to the line of code and then clicked on :hover but the script still executed and locked me out. Any other ways you can think of to prevent changes being made to a page?
Chrome allows you to disable JavaScript on certain pages, to do so click on the globe of the URL bar and it will show some permission options for the site you are. There disable JavaScript.
How to deliberately freeze javascript in chrome (plugin/console)
Found another solution in the link above:
Open Chrome javascript console
Go to "sources"
On the right side, click the little "pause" icon, or press F8 to pause script execution.
What is a good way to debug a popup window in Chrome? I need to debug some code that is run when the window is opened and I was wondering if there was a better way to debug it than pressing f12 as soon as the window opens. I'm looking for something similar to using Visual Studio where you can open a window, set a breakpoint on some JS, then open the window back up and VS will break on that breakpoint without you having to do anything.
If it can be done some way on Firefox I'd switch to that, as long as I don't have to use IE.
Nowadays there's an option in the Chrome devtools settings. "Auto-open DevTools for popups".
Check that checkbox, then if you have devtools open on the parent window and that opens a popup or new tab devtools will automatically open in that window/tab.
Short Answer:
"Ctrl + click"
Long Answer:
I had the same problem. It seems that it's a bug in Google Chrome and there's nothing we can do about it until it is fixed in future versions. I found a way around it, though, which is not an actual solution but solved my problem.
1) Close the popup window.
2) Open it again using "Ctrl + click" instead of just clicking on the link to the popup window.
3) The window will be opened in a new normal tab.
4) Now you can press F12 and go to debug mode.
Hope this solves someone else's problem too.
I'm using chrome for a new website, and I'm doing some javascript debugging.
One of my favorite techniques to debug nested expressions is to put a breakpoint, enter an expression in firebug's input panel in the console tab and press run.
But I don't see this feature in chrome. I'm probably overlooking something. Is it there? And where can I find it.
You can do it right from this page: Hit CTRL+SHIFT+J, click the Sources tab, choose chromes-alternative-for-firebug-evaluation-console from the file drop down on the left, click on line 41 to create a break point. Now refresh the page and your breakpoint will stop the debugger.
Ctrl + Shift + I will open Chrome's Developer's Tools. Or (Chrome v9): Options -> Tools -> Developer Tools. Ctrl + Shift + J is a keyboard shortcut for the Javascript console.
Under the Scripts tab, you can click on the line number to set a breakpoint.
You can also try right clicking on the page and choosing "Inspect Element" which should open the developer tools for you. Then you can click the Scripts tab like Harmen said.