在一些 Stack Overflow 问题评论之后,我更改了我的代码
<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>