Javascript 泛光灯跟踪 iframe 使浏览器窗口空白,请帮忙!
我被要求在我的网站上实现一个 javascript Floodlight 标签,每次客户下载 pdf 文件时都会调用该标签。我尝试按如下方式实现:
<script type="text/javascript">
function appForm() {
var axel = Math.random() + "";
var a = axel * 10000000000000;
document.write('<IFRAME SRC="http://fls.doubleclick.net/activityi;src=1234567;type=count123;cat=123do456;ord=1;num='+ a + '?" WIDTH=1 HEIGHT=1 FRAMEBORDER=0></IFRAME>');
return false;
}
</script>
<a href="appForm.pdf" target="_blank" onClick="appForm();">Download PDF</a>
这似乎几乎可行。 pdf 文件在新窗口中打开。但您单击下载链接的窗口会变成空白。有没有办法打开这个跟踪 iframe,然后打开 pdf,而父窗口不会变成空白?非常感谢您的帮助。
I have been asked to implement a javascript floodlight tag onto my site which is to be called everytime a customer downloads a pdf file. I have tried to implement this as follows:
<script type="text/javascript">
function appForm() {
var axel = Math.random() + "";
var a = axel * 10000000000000;
document.write('<IFRAME SRC="http://fls.doubleclick.net/activityi;src=1234567;type=count123;cat=123do456;ord=1;num='+ a + '?" WIDTH=1 HEIGHT=1 FRAMEBORDER=0></IFRAME>');
return false;
}
</script>
<a href="appForm.pdf" target="_blank" onClick="appForm();">Download PDF</a>
This seems to almost work. The pdf file opens in a new window. But the window where you clicked the download link turns blank. Is there a way of opening this tracking iframe and then having the pdf opening without the parent window going blank? Your help will be very much appreciated on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
页面加载后,无法可靠地使用 document.write()。使用更现代的
document.createElement
函数及其朋友:(未经测试,但似乎应该可以工作......)
document.write() can't be reliably used after the page has loaded. Use the more modern
document.createElement
function and its friends:(untested, but seems like it should work...)