Heey人,在下面的代码中我的会话不在IE中工作。我不知道为什么导致我没有错。
browser.php //这里php查找打开页面的浏览器:
<?php
session_start();
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') )
{
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Netscape') )
{
$browser = 'Netscape ';
}
else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') )
{
$browser = 'Firefox';
}
else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome'))
{
$browser = 'Chrome';
}
else if (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari'))
{
$browser = 'Safari';
}
}
else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') )
{
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') )
{
$browser = 'Opera ';
}
else
{
$browser = 'Explorer';
}
}
else
{
$browser = 'Others browsers';
}
$_SESSION['Ibrowser'] = $browser;
?>
Print.php //这是我想要打印pdf的页面,因为iFrame
<?php
session_start();
include("Browser.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>wk demo</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function printTrigger(elementId)
{
var browser = '<?php echo $_SESSION['Ibrowser']; ?>';
var iFramePdf = elementId;
/*alert("hello world");*/
if(browser == "")
{
alert("session is leeg");
}
else
{
if(browser == 'Explorer')
{
//alert("IE");
window.frames[iFramePdf].focus();
window.frames[iFramePdf].print();
}
else if(browser == 'Safari')
{
//alert("Safari");
window.frames[iFramePdf].focus();
window.frames[iFramePdf].print();
}
else if(browser == 'Chrome')
{
//alert("Chrome");
var getMyFrame = document.getElementById(elementId);
getMyFrame.focus();
getMyFrame.contentWindow.print();
}
else if(browser == 'Firefox')
{
//alert("Firefox");
window.open('http://62291.ict-lab.nl/Stage/VDMdm/pdf.php');
}
else
{
alert("Onbekende Browser");
}
}
}
</script>
答案 0 :(得分:4)
由于P3P (Platform for Privacy Preferences),IE存在Cookie问题和处理iFrame问题。我发现一个solution是在每个使用Cookie的页面中都包含此标题:
header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
尝试一下,让我知道它是怎么回事。