在Visual Studio 2013中调试时出现Javascript错误

时间:2022-01-16 02:56:36

I've just opened up a website for the first time in VS2013 and I'm getting Javascript exceptions when I run debugger:

我刚刚在VS2013中开辟了一个网站,当我运行调试器时,我收到了Javascript异常:

Unhandled exception at line 194, column 21 in http://localhost:49809/

0x800a1391 - JavaScript runtime error: '$' is undefined 

And here's the code:

这是代码:

<script type="text/javascript">
      $(function () {
           $('#one').ContentSlider({
                width: '960px',
                height: '250px',
                speed: 400,
                easing: 'easeOutSine'
            });
      });
 </script>

Click Continue and I get a further exception:

单击继续,我得到另一个例外:

Unhandled exception at line 37, column 59140 in http://localhost:52306/27fadf043d464a019907842c2a5a764e/browserLink

0x800a139e - JavaScript runtime error: Syntax error, unrecognized expression: unsupported pseudo: plusone

This website works fine live and debugs without issue in VS2012. I have a suspicion it's to do with referring to remote Javascript blocks (<script src="//code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> and <script type="text/javascript" src="//apis.google.com/js/plusone.js">). Is there a permissions setting I need to amend?

在VS2012中,该网站可以正常运行和调试。我怀疑它与引用远程Javascript块有关(

Any help would be greatly appreciated.

任何帮助将不胜感激。

Numb

2 个解决方案

#1


6  

It looks as though your script manager adds in the jquery reference in the body tag of a master page. You're putting in your own script and referencing jquery using the '$' symbol before the master page gets to the body tag.

看起来您的脚本管理器在主页的body标签中添加了jquery引用。在母版页到达body标记之前,您将使用'$'符号放入自己的脚本并引用jquery。

Just move your own script to after the body. If you're using a content placeholder then move the content placeholder after the body (and not in the 'head' section).

只需将自己的脚本移动到正文后面即可。如果您正在使用内容占位符,则将内容占位符移动到正文后面(而不是在“head”部分中)。

#2


28  

This seems to be a bug in the new Browser Link feature of VS 2013. See Browser Link Feature. It is a way for dynamic communication between a running app and the Visual Studio.

这似乎是VS 2013的新浏览器链接功能中的错误。请参阅浏览器链接功能。它是运行应用程序和Visual Studio之间动态通信的一种方式。

From that article, you can turn off the feature by adding the following line to Web.config:

从该文章中,您可以通过将以下行添加到Web.config来关闭该功能:

<appSettings>
  ...
  <add key="vs:EnableBrowserLink" value="false" />
</appSettings>

#1


6  

It looks as though your script manager adds in the jquery reference in the body tag of a master page. You're putting in your own script and referencing jquery using the '$' symbol before the master page gets to the body tag.

看起来您的脚本管理器在主页的body标签中添加了jquery引用。在母版页到达body标记之前,您将使用'$'符号放入自己的脚本并引用jquery。

Just move your own script to after the body. If you're using a content placeholder then move the content placeholder after the body (and not in the 'head' section).

只需将自己的脚本移动到正文后面即可。如果您正在使用内容占位符,则将内容占位符移动到正文后面(而不是在“head”部分中)。

#2


28  

This seems to be a bug in the new Browser Link feature of VS 2013. See Browser Link Feature. It is a way for dynamic communication between a running app and the Visual Studio.

这似乎是VS 2013的新浏览器链接功能中的错误。请参阅浏览器链接功能。它是运行应用程序和Visual Studio之间动态通信的一种方式。

From that article, you can turn off the feature by adding the following line to Web.config:

从该文章中,您可以通过将以下行添加到Web.config来关闭该功能:

<appSettings>
  ...
  <add key="vs:EnableBrowserLink" value="false" />
</appSettings>