URLを適当なサーバに送ってしまうバージョンです.
alertダイアログを出さずに,GETメソッドで現在のURLを裏側で送信してます.
違うのは,locationchange.jsのみです
詳しい説明は省きますが,なんとなく分かるかと思います.
07行目で一部の文字を置換しています.
apache等のウェブサーバが勝手に解釈してしまい,ログが取れないことがあります.
01: var ID = 0; 02: var SERVER = "http://hogehoge.com/"; 03: const _locationchangeListener = { 04: onStatusChange: function(){}, 05: onProgressChange: function(){}, 06: onLocationChange: function(aWebProgress, aRequest, aLocation){ 07: var query = SERVER + "?ID=" + ID + "&URL=" + aLocation.asciiSpec.replace(/#/g, "%17").replace(/&/g, "%26").replace(/=/g, "%3d"); 08: var httpReq; 09: httpReq = new XMLHttpRequest(); 10: httpReq.onload = _locationchangeHttpLoaded; 11: httpReq.onerror = function() { alert("err");}; 12: try { 13: httpReq.open("GET", query, true); 14: httpReq.send(null); 15: } catch(e) { 16: httpReq.abort(); 17: } 18: }, 19: onStateChange: function(){}, 20: onSecurityChange: function(){} 21: }; 22: function _locationchangeHttpLoaded(e) { 23: var httpReq = e.target; 24: var uri = httpReq.channel.originalURI; 25: try { 26: if(ID == 0){ 27: ID = httpReq.responseText; 28: } 29: } catch(e) { } 30: } 31: 32: function _locationchangeInstall(event) { 33: var b = getBrowser(); 34: b.addProgressListener(_locationchangeListener); 35: } 36: function _locationchangeUnInstall(event) { 37: var b = getBrowser(); 38: if(b){ 39: b.removeProgressListener(_locationchangeListener); 40: } 41: window.removeEventListener("load", _locationchangeInstall, false); 42: } 43: 44: window.addEventListener("load", _locationchangeInstall, false); 45: window.addEventListener("unload", _locationchangeUnInstall,false);