Domanda

Sto avendo problemi strani con la modalità di compatibilità IE7 e HTML5.

Sintomi: Andando direttamente alla mia homepage, usando PHP può rilevare che è IE7.Dopo aver colpito un pulsante di invio del modulo e facendo clic sul pulsante Ritorna indietro, non rileva più come IE7 anche mentre è ancora in modalità compatibilità.Deve essere aggiornato o ricaricato per rilevare come IE7 di nuovo.

Cosa posso fare per rendere questo più robusto?Per favore, non dire di utilizzare Get_Browser e Browscap.Non desidero continuare a mantenere su quel browscap.ini.

Nella testa HTML:

<?php 
    /**
    *   IE 7 has trouble with jscrollpane, so disable for all IE except for 9 which works just fine.
    */ 
    $getBrowser = $_SERVER['HTTP_USER_AGENT']; 
    if( (!stristr($getBrowser,'MSIE')) || stristr($getBrowser,'MSIE 9')):
?>
<script src="jquery/jquery.mousewheel.js"></script>
<link  rel="stylesheet" href="styles/jquery.jscrollpane.css" />
<script src="jquery/jquery.jscrollpane.min.js"></script>
<script  src="jquery/js.js"></script>
<?php endif; ?>
.

Aggiornato:

$getBrowser = $_SERVER['HTTP_USER_AGENT']; 
        if( stristr($getBrowser,'MSIE') === false)
.

RIFFETTO LINEA JS.JS A:

<!--[if IE 9 ]>
    <script  src="jquery/js.js"></script>
<![endif]-->
.

fa ancora la stessa cosa quando colpisce il pulsante indietro.

Modifica: Uomo .... Immagino che sto avendo dei seri problemi di macchina.La scatola con Windows deve essere stata avvitata dopo l'aggiornamento di Windows.Scusa per questa roba pazza.Funziona bene su un'altra macchina che non ha ancora eseguito l'aggiornamento di Windows.

È stato utile?

Soluzione

I don't have IE9 so I can't try it but can't you do something like this and place it on the <head>:

<!--[if IE 9]>
     // your includes here
<![endif]-->

Not sure if it matters to you to still see the script tags included in the source but at least it won't execute them unless the check was satisfied.

Altri suggerimenti

As @tradyblix said, you can do this client side. They're called conditional comments.

If you have to do it in the PHP, I would use strpos().

$ua = $_SERVER['HTTP_USER_AGENT'];
if (stripos($ua, 'MSIE') === false || stripos($ua, 'MSIE 9') !== false)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top