我有:
我有这些需求:
我发现了两个想法:
在test.html中:
<script type="text/javascript" src="DOMAIN_B/generator.php">
在generator.php中:
if( $_SERVER['HTTP_REFERER']=="DOMAIN_A" ) echo "<some js code>";
不幸的是,变量$ _SERVER [&#39; HTTP_REFERER&#39;]不可靠 - 来源:How reliable is HTTP_REFERER?
在test.html中:
<script>
var js = document.createElement("script");
js.type = "text/javascript";
js.src = "DOMAIN_B/generator.php?requestant_domain="+window.location.hostname;
document.body.appendChild(js);
</script>
在generator.php中:
echo "<some js code according to ".$_GET['requestant_domain'].">";
您认为最佳解决方案是什么?
您还有其他方法可以提出建议吗?