C# 当参数传递数在url-c中增加时,js文件未加载#
我在Index.aspx中创建了一个链接到母版页的按钮 在母版页中C# 当参数传递数在url-c中增加时,js文件未加载#,c#,jquery,html,asp.net,C#,Jquery,Html,Asp.net,我在Index.aspx中创建了一个链接到母版页的按钮 在母版页中 <link rel="stylesheet" href="css/bootstrap-theme.min.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script type="text/javascript" src="http://
<link rel="stylesheet" href="css/bootstrap-theme.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/lay.js"></script>
Hello.aspx页面加载时出现以下错误:
Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:64173/hello.aspx/c/js/jquery-1.11.1.min.js". 12:9
Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:64173/hello.aspx/c/js/bootstrap.min.js". 12:10
Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:64173/hello.aspx/c/js/lay.js". 12:11
Uncaught SyntaxError: Unexpected token < jquery-1.11.1.min.js:3
Uncaught SyntaxError: Unexpected token < bootstrap.min.js:3
Uncaught SyntaxError: Unexpected token <
资源解释为脚本,但使用MIME类型text/html传输:http://localhost:64173/hello.aspx/c/js/jquery-1.11.1.min.js”。12:9
解释为脚本但使用MIME类型text/html传输的资源:http://localhost:64173/hello.aspx/c/js/bootstrap.min.js". 12:10
解释为脚本但使用MIME类型text/html传输的资源:http://localhost:64173/hello.aspx/c/js/lay.js". 12:11
未捕获的语法错误:意外标记
我犯了什么错误
如果我加上
<script type="text/javascript" src="../../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../js/lay.js"></script>
然后它工作了,但是如果我将参数的数量从3增加到4,那么我必须再次添加额外的点(相对路径)才能到达那里。我们如何使它独立于传递的参数数量
TIA将CSS和JS链接更改为使用绝对路径而不是相对路径:
<link rel="stylesheet" href="/css/bootstrap-theme.min.css" />
及
前导的/
表示虚拟服务器的根,因此与当前脚本的执行位置无关。
<script type="text/javascript" src="<%=ResolveClientUrl("~/js/")%>jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="<%=ResolveClientUrl("~/js/")%>bootstrap.min.js"></script>
<script type="text/javascript" src="<%=ResolveClientUrl("~/js/")%>lay.js"></script>
上述代码有效
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/js/lay.js"></script>
<script type="text/javascript" src="<%=ResolveClientUrl("~/js/")%>jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="<%=ResolveClientUrl("~/js/")%>bootstrap.min.js"></script>
<script type="text/javascript" src="<%=ResolveClientUrl("~/js/")%>lay.js"></script>