【发布时间】:2011-05-28 13:18:29
【问题描述】:
我有以下代码在不支持 PHP 的网页中以 Javascript 模式获取引荐来源网址并将其传递给远程服务器:http://site.com/ref.php 其中$ref = $_GET['referrer']; 我得到了我想要的引荐来源网址,即站点在我的远程服务器中使用$loc = $_GET['location']; 安装脚本的位置,所以我必须在此脚本中插入document.location,但我现在不知道如何。
<script>
var src = "http://site.com/ref.php"
src += "?referrer=" + escape( document.referrer );
src += "&anticache=" + new Date().getTime();
var body = document.getElementsByTagName( "body" )[0];
var image = document.createElement( "img" );
image.src = src;
body.appendChild( image );
</script>
我已尝试添加到脚本
src += "?location=" + escape( document.location ); 但不工作
有什么帮助吗?
【问题讨论】:
-
喜欢止痛技术
-
无需将图像元素附加到正文 - 只需设置“src”属性就会导致 HTTP 事务。
标签: php javascript location referrer