代码如下。有一个文件预览按钮,它在chrome和firefox中很好地显示,但在IE中它没有显示。
$ua = htmlentities($_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, 'UTF-8');
if (preg_match('~MSIE|Internet Explorer~i', $ua) || (strpos($ua, Trident/7.0; rv:11.0') !== false)) {
// do stuff for IE
}
else{
if(strtolower($aRow["extension"])=='pdf')
{
$editable .="<a class=\"iframe\" href=\"javascript:viewPdf('http://{$_SERVER['SERVER_NAME']}{$script_dir}{
$aRow["path"]}');\" title=\"Preview\"><span class=\"glyphicon glyphicon-zoom-in\"></span></a> ";
}
答案 0 :(得分:1)
您的初始if
条件阻止Internet Explorer呈现按钮。为了在任何浏览器上显示它,您应该移动原始if-else
块之外的第二个if条件,例如:
$ua = htmlentities($_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, 'UTF-8');
if (preg_match('~MSIE|Internet Explorer~i', $ua) || (strpos($ua, 'Trident/7.0; rv:11.0') !== false)) {
// do stuff for IE
}
else {
// do stuff for other browsers that are not IE
}
if(strtolower($aRow["extension"])=='pdf') {
// render the button regardless browser User Agent (UA)
$editable .="<a class=\"iframe\" href=\"javascript:viewPdf('http://{$_SERVER['SERVER_NAME']}{$script_dir}{
$aRow["path"]}');\" title=\"Preview\"><span class=\"glyphicon glyphicon-zoom-in\"></span></a> ";
}