SCRIPT1002: Syntax error - IE10

I am using .Net 4.0 freamworok on Visual Studio 2012. My website First I started my website to get the following error in Internet Explorer 10. Other browsers (Google Chrome, Firefox ..) are working correctly.

Critical JavaScript error on line 2, column 1 in .........
SCRIPT1002: Syntax error

My jquery script file is installed on the main page.

<head runat="server">
<script src="<%# ResolveUrl("~/") %>Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>

      

I couldn't figure out the problem. Can you help me?

+3


source to share


5 answers


The full text of the SCRIPT1002 post gives a clue, namely the Syntax error script section :

Critical JavaScript error at line x, column y in siteZ.domainQ / mypage SCRIPT1002: Syntax error script section

For me, my _Layout.cshtml or Index.cshtml had virtual path references that didn't exist for scripts or styles.

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Bubble</title>
@Styles.Render("~/Content/ErrorPathDoesNotExist/css")
</head>

      



or

@section Scripts{
@Scripts.Render("~/bundles/ErrorPathDoesNotExist")
}

      

I resolved my mistake by removing or fixing invalid virtual paths in the @ Styles.Render or @ Scripts.Render statements.

For more information, refer to the Microsoft documentation on bundling, minification, and optimization.

+4


source


You probably already solved your problem. But there is still no answer. So here's another one.

I had the same error when I used const

javascript in my file. When I changed const IDLE = 0;

to var IDLE = 0;

, my problem was resolved.



Const works in chrome, Firefox en IE 11.

For more information and browser compatibility see https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Statements/const

+3


source


Sorry, I do not know English well.

I think there are some problems in your code.

  • Use single quote (') instead of double quote (") before and after server side assignment because ResolveUrl > use double quote for string argument and this sequence of double quotes is against Well-Form ness XHTML rules.

  • Use the equal sign (=) instead of the hash symbol (#) . The hash sign must be used in data binding expressions .

  • You can pass the full path of the resource up to ResolveUrl as an argument .

  • If the Scripts folder is in the root directory of the website, there is no need to use ResolveUrl ; you can simply use "/Scripts/jquery-1.7.2.min.js" as the value for the src attribute .

  • To ensure the accuracy and consistency of jQuery , download it from the official site.

  • IE 10 has some JavaScript compatibility issues. Use the X-UA-Compatible Meta Tag to regulate IE.

Your code after using the previous points:

<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=9" />
    <script src='<%= ResolveUrl("~/Scripts/jquery-1.7.2.min.js") %>' type="text/javascript"></script>    
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>

      

Or (no server side permission)

<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=9" />
    <script src="/Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>

      

Good luck!

Some useful links:

+2


source


How I solved it: -

1) removed some unused javascript code in my cshtml. 2) fix the script references to check if they point to existing libraries. 3) I was calling some javascript that didn't exist like in Ajax.BeginForm, OnSuccess = "CloseWindow ()" and CloseWindow () didn't exist, so either add the function or remove it. 4) Added this piece of code to web.config

<location path="~/Scripts">
    <system.web>
      <authentication mode="None" />
           <authorization>
                   <allow users="?"/>
             </authorization>
     </system.web>
</location>

      

I'm not sure if the fourth step is required or not. But one of the posts on Stack Overflow says: The error was that the browser needed to access the Javascript in the script folder. My project was asp.net MVC with entity framework in visual studio 2013. Hope this helps.

+2


source


I also had the same problem with my application. I removed unused script files from my ValidationScriptsPartial.cshtml page. I am developing an Asp.Net Core application.

0


source







All Articles