經過一番堆棧溢出問題的評論
<script>
//if a user is coming from
//facebook or directly from the site.
function platformAuthentication(){
var platform = "fb_platform";
if(window.self === window.top) {
platform = "web_platform";
$("#platform_key").val(platform);
$("#platform_form").submit();
}else{
platform = "fb_platform";
$("#platform_key").val(platform);
$("#platform_form").submit();
}
}
setTimeout(platformAuthentication,500);
</script>
</head>
<body>
<!--hidden form for user tracking,
if a user is coming from fb/direclty
from the site
-->
<form id="platform_form" name="platform_form" method="post" target="iframe_platform" action="url">
<input type="hidden" id="platform_key" name="platform_key" />
</form>
<iframe id="iframe_platform" name="iframe_platform" src="url">
</iframe>
基於JavaScript的解決方案,可以爲你工作,我已經改變了我的代碼? – complex857
@ complex857請詳細說明 –
在服務器端,只有第一個請求是由facebook製作的(實際上它是由用戶的瀏覽器製作的,但是從Facebook設置的參數),後來的只是鏈接或形式,並且在iframe ,從服務器端來看,這沒有什麼區別。但是,您可以通過javascript檢測您是否在iframe中。 – complex857