javascript 无法在 .js 文件内命中断点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15507349/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
can not hit breakpoint inside of .js file
提问by jim
I upgraded to win 8. Now I run my VS 2012 under admin privileges and I'm creating a website in MVC 4. I checked different solutions online and none have worked. I have a javascript file in my solution but when I put a breakpoint in it, at runtime I see "no symbols have been loaded for this document". I had this issue couple years back with VS 2008 and somehow it resolved. I don't remember if I did change anything at all. Now it's back! except i'm not on win XP and VS 2008. the .pdb files are in place (bin\Debug), script debugging is enabled in internet options, and I can debug my c# code without any problem. totally the same situation I've been into back in 2008. whatever this is, is all about javascript since this happens for inline javascript too!
我升级到了 win 8。现在我在管理员权限下运行我的 VS 2012,我正在 MVC 4 中创建一个网站。我在线检查了不同的解决方案,但没有一个有效。我的解决方案中有一个 javascript 文件,但是当我在其中放置一个断点时,在运行时我看到“没有为此文档加载任何符号”。几年前,我在 VS 2008 中遇到了这个问题,并以某种方式解决了。我不记得我有没有改变任何东西。现在它回来了!除了我不是在 win XP 和 VS 2008 上。.pdb 文件就位(bin\Debug),在 Internet 选项中启用了脚本调试,我可以毫无问题地调试我的 c# 代码。与我在 2008 年遇到的情况完全相同。无论这是什么,都是关于 javascript 的,因为内联 javascript 也会发生这种情况!
the strange part is that the js code is running but I just can't debug it in vs 2012.
奇怪的是,js 代码正在运行,但我无法在 vs 2012 中调试它。
I already know the workaround, which is using f12 tools or anything similar. That's not the case here, I had VS 2012 on win 7 two weeks ago and I was debugging my js in VS itself without any problems. this is the same installation, so it must be win 8 related.
我已经知道解决方法,即使用 f12 工具或任何类似工具。情况并非如此,两周前我在 win 7 上安装了 VS 2012,我在 VS 中调试我的 js 没有任何问题。这是相同的安装,因此必须与 win 8 相关。
So how can I solve this?
那么我该如何解决这个问题呢?
回答by abhibhatt25
You can use debugger for hitting your code. Just write
您可以使用调试器来命中您的代码。写就好了
debugger;
before the line you want to debug and this will work.I think this will make your life easy.
在您要调试的行之前,这将起作用。我认为这将使您的生活变得轻松。
回答by jim
Turn your user account control settings off!
关闭您的用户帐户控制设置!
If that doesn't work, create a new application (don't change anything!). Make sure JavaScript debugging is enabled in Internet Explorer.
如果这不起作用,请创建一个新应用程序(不要更改任何内容!)。确保在 Internet Explorer 中启用了 JavaScript 调试。
If thatdoesn't work, then make sure JavaScript is enabled in the current Internet Security Zone (IE Options).
如果这不起作用,请确保在当前 Internet 安全区域(IE 选项)中启用了 JavaScript。
回答by Hassan Rahman
By using Visual Studio 2015, I found that breakpoints will only work when you run your project in internet explorer.
通过使用 Visual Studio 2015,我发现只有在 Internet Explorer 中运行项目时,断点才会起作用。
It will neither work for Firefox nor Chrome.
它不适用于 Firefox 和 Chrome。
For Firefox you can use the Firebug (Firefox's plugin) to debug JavaScript as shown below:
对于 Firefox,您可以使用 Firebug(Firefox 的插件)来调试 JavaScript,如下所示:
回答by bmceldowney
One thing to check would be the property pages of your project to make sure your debugger type is Script Only. Just right-click on the project in the Solution Explorer and check the Debuggingpage.
要检查的一件事是项目的属性页,以确保您的调试器类型是Script Only。只需右键单击解决方案资源管理器中的项目并检查调试页面。
回答by Mehdi Karamosly
Try to put your breakpoint in the very first instruction of your JavaScript file, your breakpoint is probably in a code which is not reached.
尝试将断点放在 JavaScript 文件的第一条指令中,您的断点可能位于未到达的代码中。