日期:2014-05-16 浏览次数:20406 次
<!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" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="http://127.0.0.3/cookjs.php?webid=345"></script>
<title>引入js的页面</title>
</head>
<body>
<script type="text/javascript">
document.write("你获取另一域名的cookie值为:"+getCookie("id"));
</script>
</body>
</html>
<?
$webid=$_GET["webid"]."cc";
?>
function Setcookie (name, value)
{
var expdate = new Date();
expdate.setTime(expdate.getTime() + 30 * 60 * 1000);
document.cookie = name+"="+value+";expires="+expdate.toGMTString()+";path=/";
}
function getCookie(objName){
var arrStr = document.cookie.split("; ");
for(var i = 0;i < arrStr.length;i ++){
var temp = arrStr[i].split("=");
if(temp[0] == objName) return unescape(temp[1]);
}
}
Setcookie("id","<?=$webid;?>");