Javascript Internet Explorer浏览器中未显示“Php文件预览”按钮

Javascript Internet Explorer浏览器中未显示“Php文件预览”按钮,javascript,php,internet-explorer,internet-explorer-11,Javascript,Php,Internet Explorer,Internet Explorer 11,代码如下。在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(strtol

代码如下。在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>&nbsp;";
}
$ua=htmlentities($\u服务器['HTTP\u用户\u代理'],ENT\u引号,'UTF-8');
if(preg|u match('~MSIE | internetexplorer~i',$ua)|(strpos($ua,Trident/7.0;rv:11.0')!=false)){
//为我做事
}
否则{
if(strtolower($aRow[“extension”])=='pdf')
{ 
$可编辑。=“”;
}

您的初始
if
条件阻止Internet Explorer呈现按钮。为了在任何浏览器上显示该按钮,您应该将第二个if条件移动到原始
if else
块之外,例如:

$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>&nbsp;";
}
$ua=htmlentities($\u服务器['HTTP\u用户\u代理'],ENT\u引号,'UTF-8');
if(preg|u match('~MSIE | internetexplorer~i',$ua)|(strpos($ua,'Trident/7.0;rv:11.0')!=false)){
//为我做事
}
否则{
//为其他非IE浏览器做一些事情
}
如果(strtolower($aRow[“extension”])=='pdf'){
//不管浏览器用户代理(UA)如何呈现按钮
$可编辑。=“”;
}