Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Developer Tools can't see javascript

So I am having this really weird thing where my javascript doesn't show in my sources window. If I set a debugger in my js and then reload the page, it will break and I can see the javascript. The weird thing is that instead of the tab being labeled MyJavascriptFile.js it reads [VM](62) or some other number. I have tried reinstalling chrome and it didnt fix my problem. It didn't used to be like this, any ideas what is going on? Its just really annoying to have get to my javascript by adding debugger statements.

like image 749
jensengar Avatar asked Jun 13 '13 14:06

jensengar


People also ask

How do I view JavaScript code in Chrome developer tools?

The Sources panel is where you debug JavaScript. Open DevTools by pressing Command+Option+I (Mac) or Control+Shift+I (Windows, Linux). This shortcut opens the Console panel. Click the Sources tab.

How do I view JavaScript in dev tools?

You can do this with the keyboard using the shortcut CMD-OPT-I on macOS or CTRL-SHIFT-I on Windows. The Dev Tools will now be open inside the browser tab, and the Console tab will be active. This tab allows you to execute arbitrary JavaScript code at any time or to view any outputs from console.

Why is JavaScript not working in Chrome?

Google ChromeIn the "Settings" section click on the "Show advanced settings..." Under the the "Privacy" click on the "Content settings...". When the dialog window opens, look for the "JavaScript" section and select "Allow all sites to run JavaScript (recommended)". Click on the "OK" button to close it.

How do I enable JavaScript in Chrome console?

Press Command+Option+J (Mac) or Control+Shift+J (Windows, Linux, ChromeOS) to open the Console, right here on this very page.


2 Answers

I'm having this problem right now. Must be a bug in Chrome. All you have to do is load the console (f12) then reload the page whilst the console is loaded. You can now see your code.

like image 89
Welshboy Avatar answered Sep 28 '22 18:09

Welshboy


The weird thing is that instead of the tab being labeled MyJavascriptFile.js it reads VM or some other number.

This is because you are accessing your script through localhost, and therefore running into security policies. If you host your file at an IP or domain name, you'll be able to debug normally again.

like image 44
Paul S. Avatar answered Sep 28 '22 19:09

Paul S.