所以有2个网站A和B.
A有一个带iframe的页面加载B. 并且B具有检测访问者IP地址的后端代码,如下所示:
// Function to get the user IP address
function getUserIP() {
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_FORWARDED']))
$ipaddress = $_SERVER['HTTP_FORWARDED'];
else if(isset($_SERVER['REMOTE_ADDR']))
$ipaddress = $_SERVER['REMOTE_ADDR'];
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
如果用户访问A中的iframe页面,将获取哪个IP地址?
是客户的IP地址吗,
或
网站A的IP地址?
答案 0 :(得分:3)
iframe元素代表nested browsing context。用户浏览器请求iframe源。因此,如果您检查IP地址,您将获得客户端IP。
答案 1 :(得分:0)
我猜它仍会获得客户端的IP地址? 因为iframe会发送几乎相同的标题。
也将发送客户端IP地址。