在iframe框架中取得的referer,是该iframe中地址,而不是嵌套该iframe地址。
代码
文件名:iframe-index.html
文件名:iframe-child.html
文件名:iframe-success.php
截图如下:
[img]http://dl.iteye.com/upload/attachment/0067/5438/96898e57-2b3e-37eb-bd77-fa22998077a6.png[/img]
[img]http://dl.iteye.com/upload/attachment/0067/5440/7eb8a3c6-9256-3c0a-94dd-ae790f2042b7.png[/img]
代码
文件名:iframe-index.html
<html>
<head>
<title>测试iframe页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
</head>
<body>
<div>
当前页面url:/iframe-index.html<br />
Helloworld<br />
下面是iframe嵌套页面<br />
</div>
<div>
<iframe src="/iframe-child.html" width="500"/>
</div>
</body>
<html>
文件名:iframe-child.html
<html>
<head>
<title>iframe子页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
</head>
<form action="/iframe-success.php">
当前页面url:/iframe-chlid.html<br />
子页面的iframe
<input type="submit" name="提交"/>
</form>
<html>
文件名:iframe-success.php
<?php
echo "http_referer=";
echo $_SERVER['HTTP_REFERER'];
echo "<br />";
echo "跳转成功!";
?>
截图如下:
[img]http://dl.iteye.com/upload/attachment/0067/5438/96898e57-2b3e-37eb-bd77-fa22998077a6.png[/img]
[img]http://dl.iteye.com/upload/attachment/0067/5440/7eb8a3c6-9256-3c0a-94dd-ae790f2042b7.png[/img]