2013-06-30 12 views
6

Sono di fronte a qualche problema con IE7/IE8 e jQuery. Il mio codice funziona in IE 10, FF, Chrome, Safari, Mobile Safari, Mobile Chrome.IE8 genera un errore con jQuery

Per il debug, ho rimosso il mio file JS. Quindi, ecco il codice:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> 
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> 

Non vi sono altri JS a cui si fa riferimento in questa pagina. Ho rimosso tutti gli altri riferimenti JS e non è stato eseguito JS sulla pagina stessa. Quando la pagina viene caricata in IE8, ottengo questo errore:

Line: 4 
Error: Object doesn't support this property or method 

enter image description here

Il debugger mostra quanto sopra. Non sono sicuro di quale sia il problema. Qualsiasi aiuto è molto apprezzato.

P.S. - Questo è il mio primo sforzo di sviluppo web "serio" e ora vedo perché IE è odiato così tanto nella comunità di sviluppatori.

risposta

13

jQuery 2.0 ha abbandonato il supporto per alcuni browser. Vedere il post di rilascio a http://blog.jquery.com/2013/04/18/jquery-2-0-released/

Citando da posta:

No more support for IE 6/7/8: Remember that this can also affect IE9 and even IE10 if they are used in their “Compatibility View” modes that emulate older versions. To prevent these newer IE versions from slipping back into prehistoric modes, we suggest you always use an X-UA-Compatible tag or HTTP header. If you can use the HTTP header it is slightly better for performance because it avoids a potential browser parser restart.

Reduced size: The final 2.0.0 file is 12 percent smaller than the 1.9.1 file, thanks to the elimination of patches that were only needed for IE 6, 7, and 8. We had hoped to remove even more code and increase performance, but older Android/WebKit 2.x browsers are now the weakest link. We’re carefully watching Android 2.x market share to determine when we can cross it off the support list, and don’t expect it to take very long.

Tenere jQuery 1.9 (Edit 2015/11/17:. JQuery 1.11.3 è la versione 1.x corrente di jQuery) se IE 6/7/8 sono una preoccupazione.

+0

A volte, si deve guardare alla fonte del codice per determinare il problema. Grazie! –

+0

GRAZIE! Stavo sbattendo la testa contro il muro cercando di capire perché la mia applicazione non funzionava in IE8 (sì, abbiamo ancora utenti con XP, sfortunatamente). Era perché stavo usando la versione di jQuery installata da NuGet in Visual Studio 2012. – timbck2

0

Ho affrontato lo stesso problema, gli script In realtà stavo REFERENCING come questo;

<script src="../js/jquery-ui.js" type="text/javascript"></script> 
<script src="../js/jquery.min.js" type="text/javascript"></script> 

Ho riparato questo cambiando script ordine riferimento chiamando jquery.min.js prima.

<script src="../js/jquery.min.js" type="text/javascript"></script> 
<script src="../js/jquery-ui.js" type="text/javascript"></script> 

Aggiungere il seguente nel web.config:

<system.webServer> 
    <httpProtocol> 
     <customHeaders> 
     <add name="X-UA-Compatible" value="IE=EmulateIE8" /> 
     </customHeaders> 
    </httpProtocol> 
</system.webServer>