开发者

Internet explorer global javascript files

I am building a PHP MVC website and I include several js files.. The problem I encounter is that if I have for example a js file containing functions and needed variables I can't use them in other js files (I call the functions using document.ready() and I use mostly jQuery to make ajax calls). It works fine in Firefox but IE throws an error... I include the js files using a html class:

function includeJs($fileName) {
    $data = '<script src="'.BASE_PATH.'/public/js/'.$fileName.'.js" type="text/javascript"></script>';
    return $data;
}

This is the error I'm getting:

Webpage error details
User Agent: Mozilla/4.0 (compatible; MSI开发者_JAVA百科E 8.0; Windows NT 6.1; Trident/4.0;
            SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729;
            Media Center PC 6.0; InfoPath.3; .NET CLR 1.1.4322)
            Timestamp: Thu, 3 Mar 2011 11:53:33 UTC

Message: Expected identifier Line: 26 Char: 21 Code: 0
         URI: http://localhost/learning/public/js/general.js
Message: Object expected Line: 5 Char: 3 Code: 0
         URI: http://localhost/learning/public/js/tests.js


It sounds like you have a syntax error in your js file that is only a problem for ie and not firefox.

Typically this type of error is a trailing comma in an array or an object.

For instance [1,2,3,] is valid in firefox, but not in ie. To make this valid in ie you need to remove the trailing comma, so it looks like [1,2,3].

The same goes for objects so if you have { foo: 1, bar: 2,} it will fail in ie but not in firefox.


You trouble could be JQuery!

If you must use JQuery (Latest fab) then don't rely on Googles hosting a copy for you because IE8/9 sees Google for what it is, a tracker and blocks the .js file if tracking protection is turned on.

Real pain to sort out as it can take a week for IE8/9 to start blocking the files from Google and that also goes for the new Google Plus button that uses HTTPS to spy on people and yes i have peeked at Googles .js to know what i am talking about.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜