¿Por qué el botón Atrás del compatibilidad de IE7 PHP no puede detectar IE7?
-
14-11-2019 - |
Pregunta
Tengo problemas extraños con el modo de compatibilidad de IE7 y HTML5.
Síntomas: Ir directamente a mi página de inicio, usar PHP puede detectar que es IE7.Después de golpear un botón de envío de forma, y hacer clic en el botón Volver atrás, ya no se detecta como IE7 incluso mientras aún está en modo de compatibilidad.Debe ser actualizado o recargado para detectar como IE7 nuevamente.
¿Qué puedo hacer para hacer esto más robusto?Por favor, no digas que use get_browser y browscap.No deseo seguir manteniendo en ese browscap.ini.
en la cabeza 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; ?>
Actualizado:
$getBrowser = $_SERVER['HTTP_USER_AGENT'];
if( stristr($getBrowser,'MSIE') === false)
Línea reubicada JS.JS a:
<!--[if IE 9 ]>
<script src="jquery/js.js"></script>
<![endif]-->
todavía hace lo mismo al golpear el botón Atrás.
Editar: Hombre .... Supongo que estoy teniendo algunos problemas de máquina serios.La caja con Windows debe haber sido atornillada después de la actualización de Windows.Lo siento por esta cosa loca.Funciona bien en otra máquina que aún no ha corrido Windows Update.
Solución
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.
Otros consejos
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)