Created
October 12, 2015 04:12
-
-
Save binderclip/437fbc9c3a6a78a8dd43 to your computer and use it in GitHub Desktop.
简单的广告统计测试页面
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>广告统计</title> | |
<script src="jquery.js"></script> | |
</head> | |
<body> | |
<a href="http://localhost:8000/apple" ad-load-url="http://localhost:8000/apple/load" ad-click-url="http://localhost:8000/apple/click">apple</a> | |
<a href="http://localhost:8000/orange" ad-load-url="http://localhost:8000/orange/load" ad-click-url="http://localhost:8000/orange/click">orange</a> | |
<a href="http://localhost:8000/banana">banana</a> | |
<a href="http://localhost:8000/watermelon">watermelon</a> | |
<script type="text/javascript"> | |
// 获取元素测试 | |
// console.log($("a")); | |
// console.log($("[ad-load-url]")); | |
// console.log($("[ad-click-url]")); | |
// 绑定事件,打印自己的内容 | |
$(function(){ | |
var ads_load = $("a[ad-load-url]"); | |
var ads_click = $("a[ad-click-url]"); | |
// console.log(ads_load); | |
// console.log(ads_click); | |
// 加载完成加载 | |
ads_load.each(function() { | |
sendAdLog($(this).attr("ad-load-url")); | |
}); | |
// 绑定点击事件 | |
ads_click.each(function() { | |
$(this).click(function() { | |
sendAdLog($(this).attr("ad-click-url")) | |
}); | |
}); | |
function sendAdLog(url){ | |
// 简单打印 | |
// console.log("url: " + url); | |
// 发送请求 | |
var sender = new Image(); | |
sender.src = url; | |
} | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
整理出来的格式: