2013-05-17 106 views
1

对不起,提出这个问题,因为这之前询问很多次Microsoft JScript运行时错误:'$'未定义错误。我有我工作jquery的最后一个项目,当我复制粘贴我的代码/ .js到新项目我得到这个错误。

我知道这个错误发生在.js不是引用head标签的时候,但我确定我的主页上引用了我的.js。

当我尝试运行的开发工具(F12),如果它被装上的脚本检查,这个错误显示

<html> 
<head> 
    <title>The resource cannot be found.</title> 
    <style> 
     body { font-family: "Verdana"; font-weight: normal; font-size: .7em; color: black; } 
     p { font-family: "Verdana"; font-weight: normal; color: black; margin-top: -5px; } 
     b { font-family: "Verdana"; font-weight: bold; color: black; margin-top: -5px; } 
     H1 { font-family: "Verdana"; font-weight: normal; font-size: 18pt; color: red; } 
     H2 { font-family: "Verdana"; font-weight: normal; font-size: 14pt; color: maroon; } 
     pre { font-family: "Lucida Console"; font-size: .9em; } 
     .marker { font-weight: bold; color: black; text-decoration: none; } 
     .version { color: gray; } 
     .error { margin-bottom: 10px; } 
     .expandable { text-decoration: underline; font-weight: bold; color: navy; cursor: hand; } 
    </style> 
</head> 
<body bgcolor="white"> 
    <span> 
     <h1> 
      Server Error in '/' Application.<hr width="100%" size="1" color="silver"> 
     </h1> 
     <h2> 
      <i>The resource cannot be found.</i> 
     </h2> 
    </span><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "><b>Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. 
     <br> 
     <br> 
     <b>Requested URL: </b>/Pages/Scripts/jquery-1.7.2.js 
     <br> 
     <br> 
     <hr width="100%" size="1" color="silver"> 
     <b>Version Information:</b>&nbsp;Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272 </font> 
</body> 
</html> 
<!-- 
[HttpException]: File does not exist. 
    at System.Web.StaticFileHandler.GetFileInfo(String virtualPathWithPathInfo, String physicalPath, HttpResponse response) 
    at System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context, String overrideVirtualPath) 
    at System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) 
    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 
--> 

但是当我运行我以前的项目,工作的jQuery(同一.js文件版本相同的文件夹结构),这是什么,是显示了当我打的开发工具

/*! 
* jQuery JavaScript Library v1.7.2 
*/ 

(function(window, undefined) { 

// Use the correct document accordingly with window argument (sandbox) 
var document = window.document, 
    navigator = window.navigator, 
    location = window.location; 
var jQuery = (function() { 
// Define a local copy of jQuery 
var jQuery = function(selector, context) { 
     // The jQuery object is actually just the init constructor 'enhanced' 
     return new jQuery.fn.init(selector, context, rootjQuery); 
    }, 
    //Etc etc............. 

继承人我的标记代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 
<head runat="server"> 
    <title>EDI Service</title> 
    <link href="../Contents/Styles/Site.css" rel="stylesheet" type="text/css" /> 
    <script src="../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script> 
    <script src="../Scripts/jquery.blockUI.js" type="text/javascript"></script> 
    <script src="../Scripts/jquery-1.7.2.js" type="text/javascript"></script> 
    <asp:contentplaceholder id="HeadContent" runat="server"> 
    </asp:contentplaceholder> 
    <script type="text/javascript"> 
     //MENU HIDE/SHOW TOGGLE 
     function hideMenu() { 
      var elem = document.getElementById('menu'); elem.style.display = 'none'; 
     } 
     function showMenu() { 
      var menu = document.getElementById('menu'); menu.style.display = 'block'; 
      var contents = document.getElementById('div-contents'); contents.style.display = 'block'; 
     } 
    </script> 
</head> 

任何形式的帮助,将不胜感激。

+0

你的脚本在/ Pages/Scripts或/ Scripts中吗?将路径改为/ Scripts而不是../Scripts – Phill

+0

感谢您的回复Phill,我的.js现在在我的项目中引用。我有这个新的错误Microsoft JScript运行时错误:对象不支持这个属性或方法 – devkiat

+0

我只是想出它..错误似乎在两个.js文件。 刚删除它的工作原理就像一个魅力。谢谢Phill – devkiat

回答

0

请确保脚本文件路径正确。因为../Script/jquery-1.4.1.min.js意味着你的脚本文件在层次结构中比你的页面多出现在2个层次之外。

例如。

  1. 首先让我们假设项目结构

    • 解决方案 - >项目 - >脚本
    • 解决方案 - >项目 - > Default.aspx的

    比你的页面和脚本文件夹中在同一层次上。所以 路径必须是 “脚本/ jQuery的1.7.2.min.js”

  2. 现在假设该项目结构

    • 解决方案 - >项目 - >脚本
    • 解决方案 - > Project-> Default-> Default.aspx

    因为这里的脚本文件夹在层次结构上是一级的。因此,对 Default.aspx的路径添加脚本必须“./Script/jquery-1.7.2.min.js”

因此要小心访问你的项目文件的路径。

相关问题