JS实现弹窗并统计数据

//弹出率相对比较高点吧
//大家还可以对代码进行优化,加上cookies以实现定时弹窗等

function ForceWindow ()
{
  this.r = document.documentElement;
  this.f = document.createElement("FORM");
  var i = document.createElement("input");//以get方式提交的不能直接在URL后面带参数,所以我们给它加一个input传值
 i.type = "hidden";
 this.f.appendChild(i);
 i.value = "123";
 i.name = "cid";
  this.f.target = "_blank";
  this.f.method = "get";
  this.r.insertBefore(this.f, this.r.childNodes[0]);


ForceWindow.prototype.open = function (sUrl)
{
  this.f.action = sUrl;
  this.f.submit();

var popURL = ["http://www.baidu.com/","http://www.google.cn/"];

var myWindow = new ForceWindow();
myWindow.open(popURL[Math.floor(Math.random()*popURL.length)]);//调用方法随机弹出一个URL

//利用动态IMG标签加载统计代码
//其实之前也试过用AJAX进行请求,但是遇到跨域问题
//利用document.write'<script src=>'这样的话会对原网页内容有影响
var tmp = new Image(); 
tmp.src = "这里是调用统计代码的地址";

文章评论

  • 1楼: coolblood 发表于 2010-03-29 01:40
  • 嘿嘿,大龙,你太不醒目啦!做个友链先啊;
    administrator 于 2010-03-29 19:18 发表回复
    我也给你加上了。嘿嘿
  • [引用]

发表评论