Home > Web Front-end > JS Tutorial > [JS] Click out statistician_javascript skills

[JS] Click out statistician_javascript skills

WBOY
Release: 2016-05-16 19:27:33
Original
966 people have browsed it

ff The default is not allowed to change status
opera9 Test passed
ie6 Test passed

This thing is used by the statistics department to analyze user habits to improve the website layout.
It’s just a little thing written for fun, so many places are not ideal.

The save() method is to save the record. If you don’t do it carefully, you should add a judgment browser, and then decide to use img or iframe to ensure that the request can be sent. The
onclick() method is How to use

to be executed when an event is triggered:

Add
script src="clickout.js"> to any page.
It is best to put In front of , the purpose is to prevent onclick event coverage.


[Ctrl A select all Note:
If you need to introduce external Js, you need to refresh to execute <script> /* * 说明:点出统计器 * 作者:邓威 * 日期:2006-07-25 * 版本:v1.0 */ <P>function ClickOut() { this.oCO = null; this.src_onclick = null; this.isDEBUG = true || "status"; <P> this.debug = function(arg) { if( this.isDEBUG == "status" ) window.status = arg.toString(); else if ( this.isDEBUG ) alert(arg.toString()); } <P> this.save = function() { var sUrl = "clickout.php?"; sUrl += "tag=" + encodeURIComponent(this.click_tag); sUrl += "&type=" + encodeURIComponent(this.click_type); sUrl += "&src=" + encodeURIComponent(this.click_src); sUrl += "&text=" + encodeURIComponent(this.click_text); this.oCO = document.createElement('<div id="ClickOut" style="width:0px;height:0px;">'); document.body.appendChild(this.oCO); document.getElementById("ClickOut").innerHTML = '<img src="' + sUrl + '" style="max-width:90%" style="max-width:90%" height="0px" \/ alt="[JS] Click out statistician_javascript skills" >'; return true; } <P> this.onclick = function(args) { if( this.src_onclick != null ) this.src_onclick(e); var obj = event.srcElement; var tag = obj.tagName.toLowerCase(); this.click_id = obj.id?obj.id:null; this.click_class = obj.className?obj.className:null; this.click_name = obj.name?obj.name:null; this.click_tag = tag; this.click_parent = obj; this.click_obj = obj; this.click_path = tag; <P> if( tag == "a" ) { this.click_type = "text"; this.click_src = obj.href; this.click_text = obj.innerHTML; } else if ( tag == "img" ) { this.click_type = "pic"; this.click_src = obj.src; this.click_text = obj.alt; } else if ( tag == "font" || tag == "b" || tag == "strong" ) { this.click_type = "text"; this.click_src = ""; this.click_text = obj.innerHTML; } else { this.click_type = "layer"; this.click_src = "" ; this.click_text = obj.innerHTML; } this.GetParent(); <P> this.debug(this.click_path); doSave(); } <P> this.GetParent = function() { if( !this.click_parent.parentNode.tagName ) return; this.click_parent = this.click_parent.parentNode; this.click_path = this.click_parent.tagName.toLowerCase() + "[ " + (this.click_parent.id?("ID:" + this.click_parent.id):"") + (this.click_parent.className?(" ,CLASS:" + this.click_parent.className):"") + (this.click_parent.name?(" ,NAME:" + this.click_parent.name):"") + " ]" + ">" + this.click_path; this.GetParent(); } } <P>// 实例 var objCO = new ClickOut(); // 保存原有的 onclick 事件 objCO.src_onclick = document.onclick; <P>function click_tmp() { objCO.onclick(); } function doSave() { objCO.save(); } <P>// bind event document.onclick = click_tmp; <P> <P> </script>]
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template