开发者

When I include only the jQuery 1.4 Library, I get an exception, why?

I keep getting this error all over the place where I only have jquery 1.3 or 1.4 included.

"setting a property that has onl开发者_运维百科y a getter"

and a long list of warnings in the Firefox Error Console.

What's going on? I can't find any information on this issue =/

<!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-US">
<head>
  <title>Demo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <link rel="shortcut icon" href="images/favicon.ico">
    <link rel="stylesheet" href="css/common.css" type="text/css" /> 
    <link rel="stylesheet" href="css/modules.css" type="text/css" /> 
    <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> 
</head>  

Just some Warning snippets:

Warning: reference to undefined property a[++e] 
Source File: /js/jquery-1.4.2.min.js 
Line: 30 
Warning: reference to undefined property a[0] 
Source File: /js/jquery-1.4.2.min.js 
Line: 30 
Warning: function oa does not always return a value 
Source File: /js/jquery-1.4.2.min.js Line: 18, Column: 165 
Source Code: th;n<r;n++){j=d[n];a.currentTarget=j.elem;a.data=j.handleObj.data;a.handleObj=j.handleObj;if(j.handleObj.origHandler.apply(j.elem,e)===false){b=false;break}}return b}}function pa(a,b){return"live."+(a&&a!=="*"?a+".":"")+b.replace(/\./g,"`").replace(/ /g,


Do you have a "use strict"; statement anywhere? That causes ECMAScript5 browsers to parse JavaScript a little different and could cause this to be returned as an error.

You can remove this to fix the error, but that means you don't benefit from use strict. Note that use strict works in whatever scope it is executed in. So, if you want to load jQuery as non-strict, but have the rest of your code be strict, you can do this:

//load jQuery here

//create a scope
(function() {
     "use strict";
     // your code here
})();


Although this question has already been answered, I felt this was necessary.

OP probably has strict warnings turned on in his about:config in Firefox.

To change this just load up about:config in Firefox then scroll down to javascript.options.strict and then change this value to "false".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜