嘿人,在下面的代碼中,我的會話在IE中不工作。我不知道爲什麼導致我沒有什麼不對。PHP會話不能在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>
它在IE中做錯了什麼? –
你確定,你包含的文件** Browser.php **不是** browser.php **? –
如何刪除歌劇結束時的空間$ browser ='Opera'; ' – rauschen