在IE 8中查看网站时无法加载本地JQuery文件(Cannot load local JQuery file when viewing site in IE 8)

编程入门 行业动态 更新时间:2024-10-28 09:25:00
在IE 8中查看网站时无法加载本地JQuery文件(Cannot load local JQuery file when viewing site in IE 8)

我试图使用datetimepicker控件(http://timjames.me/jquery-ui-datetimepicker-plugin),但看起来我的本地js文件加载有问题 - 但只在IE(版本8.0.6)中工作在Firefox 18.0版中很好。

我使用一个以占位符“MainContent”命名的母版页,因此我的所有子页面控件都需要由MainContent_引用,后跟控件的ID。

母版页中的元素包含以下脚本:

<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.min.js"></script> <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.16/jquery-ui.min.js"></script> <link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.16/themes/hot-sneaks/jquery-ui.css" /> <script type="text/javascript" src="Scripts/jquery-ui-timepicker-addon.js"></script> <script type="text/javascript"> $(document).ready(function () { alert("hello"); $('#MainContent_calStart').datetimepicker(); }); </script> script language="javascript" type="text/javascript"> function GetItem(strName) { return document.all ? document.all[strName] : document.getElementById(strName); } ... etc etc etc

我的asp.net子页面包含代码:

基本上,托管datetimepicker的页面不是网站中加载的第一个页面,但由于包含脚本的母版页包含(并且无法全部加载),网站的第一页加载了js错误。

我在使用IE时无法加载/包含任何本地JQuery文件到我的网站,因为我收到Javascript错误:

网页错误详情

用户代理:Mozilla / 4.0(兼容; MSIE 8.0; Windows NT 5.1; Trident / 4.0; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1。 4322; .NET4.0C; .NET4.0E)时间戳:星期二,2013年1月15日13:31:47 UTC

消息:语法错误行:3个字符:1代码:0 URI :( localhost上的页面路径)

该网站炸弹在$('#MainContent_calStart')行.datetimepicker(); 错误“Microsoft JScript运行时错误:对象不支持此属性或方法”表示浏览器无法从包含文件中找到datetimepicker小部件的源/声明。 如果我继续加载网站,尽管js错误,datetimepicker小部件加载并似乎完全正常。

奇怪的是,如果我在VS2010中获取代码并创建示例网站项目,并包含上述文件/代码,则示例站点可以正常工作。 示例和我的实时站点之间的唯一区别是在实时站点中有其他页面/ css / js文件。 两个站点的结构在脚本位置/ css位置等方面是相同的。示例站点在IE和FF中都能正常工作。

最后一点,如果我将所有代码从jquery-ui-timepicker-addon.js移动到母版页本身并排除js文件,该网站就可以工作了。 这指出了在本地文件中没有加载js代码的事实。

任何帮助表示赞赏。 干杯。

吉米

PS。 我不能包含任何本地js文件,而不仅仅是有问题的文件。

I am attempting to use the datetimepicker control (http://timjames.me/jquery-ui-datetimepicker-plugin) but it appears my local js file is having trouble loading - but only in IE (version 8.0.6) as it works fine in Firefox version 18.0.

I use a master page named with placeholder "MainContent" so all of my child page controls need to be referenced by MainContent_ followed by the ID of the control.

The element in the master page contains the following script includes:

<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.min.js"></script> <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.16/jquery-ui.min.js"></script> <link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.16/themes/hot-sneaks/jquery-ui.css" /> <script type="text/javascript" src="Scripts/jquery-ui-timepicker-addon.js"></script> <script type="text/javascript"> $(document).ready(function () { alert("hello"); $('#MainContent_calStart').datetimepicker(); }); </script> script language="javascript" type="text/javascript"> function GetItem(strName) { return document.all ? document.all[strName] : document.getElementById(strName); } ... etc etc etc

My asp.net child page contain the code:

Basically, the page hosting the datetimepicker is not the first page loaded in the site, but due to the master page containing the script includes (and being unable to load them all), the first page of the site loads with js errors.

I cannot load/include ANY local JQuery files in to my site when using IE as I get Javascript error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E) Timestamp: Tue, 15 Jan 2013 13:31:47 UTC

Message: Syntax error Line: 3 Char: 1 Code: 0 URI: (path to page on localhost)

The site bombs at line $('#MainContent_calStart').datetimepicker(); with error "Microsoft JScript runtime error: Object doesn't support this property or method" indicating the browser has been unable to find the source/declarations for the datetimepicker widget from within the include file. If I continue loading the site despite the js error, the datetimepicker widget loads and appears to be fully functional.

The strange thing is, if I take the code and create a sample website project in VS2010, and include the files/code as above, the sample site works. The only difference between the sample and my live site is there is additional pages/css/js files in the live site. The structure of the 2 sites is the same in terms of script locations/css locations etc. The sample site works fine in both IE and FF.

One final thing, if I move all of the code from jquery-ui-timepicker-addon.js into the master page itself and exclude the js file, the site works. This points to the fact the js code is not being loaded when in a local file.

Any help is appreciated. Cheers.

Jimmy

PS. I cannot include ANY local js file, not just the one in question.

最满意答案

当我使用一个使用indexOf的插件(也在jQuery插件本身中)时,我在IE8中遇到了同样的错误(Object不支持这个属性或方法)(http://www.w3schools.com/jsref/jsref_indexof.asp )。 在IE8中以某种方式不支持此功能。 我将此函数更改为jQuery的in.Array函数(http://api.jquery.com/jQuery.inArray/),并且足够愚蠢:这也使用indexOf。

为了解决这个问题,我将这个函数替换为for循环,它只搜索解决了我在IE8上的问题的数组/字符串/ ....

我希望它有所帮助!

I had the same error (Object doesn't support this property or method) in IE8 when I used a plugin (also in the jQuery plugin itself) which used indexOf (http://www.w3schools.com/jsref/jsref_indexof.asp). This function is somehow not supported in IE8. I changed this function to in.Array function of jQuery (http://api.jquery.com/jQuery.inArray/), and stupid enough: this also uses indexOf.

To solve it, I replaced this function for a for-loop which searches the array/string/... only that solved my problem on IE8.

I hope it helps!

更多推荐

本文发布于:2023-08-05 21:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1440266.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   文件   网站   JQuery   load

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!