을로드하기 위해 두 번째 줄과 세 번째 줄은 script
태그를 문서에 삽입하고 있습니다. 페이지의 프로토콜이 http
인 경우 , https
인 경우 https
인 경우 http
을 사용합니다. (more here). 페이지의 리퍼러를 스크립트로로드하는 GET에 전달합니다 (&
은 zzzzz
으로 바뀜). munique
매개 변수는 현재 날짜의 숫자 버전을 가져옵니다. 캐싱을 무효화하려는 시도로
unescape
호출과 인코딩 된 문자 이유는 당신이 script
태그 내부의 자바 스크립트 코드의 문자열 내부 </script>
이있는 경우는 조기에 스크립트 태그를 오게됩니다. (JavaScript 코드가 자체 파일에 있어야하는 몇 가지 이유 중 하나입니다.) 따라서 대괄호를 인코딩하고 unescape
을 사용하여 HTML 파서가 </script>
으로 표시되는 것을 피합니다.
업데이트 : 당신은 당신이 window.load
에서 그 코드를 사용하려는 말했다 아래. 페이지의 초기 구문 분석 중에 만 document.write
을 사용할 수 있기 때문에 그렇게 할 수 없습니다. (나중에 그것을 사용하는 경우, 그것은 — 그것을 지우고 다음 새, 빈 문서에 기록 문서 — 다시 열립니다.)
당신은,하지만, 나중에 다른 메커니즘 (갱신를 통해 script
태그를 추가 할 수 있습니다 : 죄송합니다, 당신이 jQuery를 사용하고 놓쳤다; 맨 아래에 jQuery를 버전)입니다 :
<script type="text/javascript">
window.onload = function() {
// Get the referrer, replacing `&` with `zzzzz`
var thisref = document.referrer.replace(/&/g, "zzzzz");
// Get the protocol to use based on the current document's protocol
var ciJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
// Create a script element, set its type and src
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = ciJsHost
+ "tracking.callmeasurement.com/clickx/click_matrix.cfm?munique="
+ new Date().getTime()
+ "&prev=" + thisref;
// Add it just about anywhere; `document.body` works fine and is
// easy. The script is downloaded and executed when you do the append.
document.body.appendChild(script);
};
</script>
을 또는 프로토콜에 대한 트릭 I linked to above을 사용하려면 :
<script type="text/javascript">
window.onload = function() {
// Get the referrer, replacing `&` with `zzzzz`
var thisref = document.referrer.replace(/&/g, "zzzzz");
// Create a script element, set its type and src
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "//tracking.callmeasurement.com/clickx/click_matrix.cfm?munique="
+ new Date().getTime()
+ "&prev=" + thisref;
// Add it just about anywhere; `document.body` works fine and is
// easy. The script is downloaded and executed when you do the append.
document.body.appendChild(script);
};
</script>
thisref
부분에는 별도의 변수가 필요하지 않습니다. 그 변화하고 위의 설명 밖으로 제거 : 마지막으로
<script type="text/javascript">
window.onload = function() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "//tracking.callmeasurement.com/clickx/click_matrix.cfm?munique="
+ new Date().getTime()
+ "&prev=" + document.referrer.replace(/&/g, "zzzzz");
document.body.appendChild(script);
};
</script>
그리고을, 나는 당신이 한판 승부 'jQuery를, 미안 사용하고 있음을 놓쳤다 :
<script type="text/javascript">
$(window).load(function() {
$("<scr" + "ipt type='text/javascript' src='//tracking.callmeasurement.com/clickx/click_matrix.cfm?munique="
+ new Date().getTime()
+ "&prev=" + document.referrer.replace(/&/g, "zzzzz") + "'></src" + "ipt>")
.appendTo(document.body);
});
</script>
을 ... 오히려 jQuery(...
을 고려할 수 있지만, $(window).load(...
보다 큰 이미지가 필요합니다. 모든 이미지와로드가로드 될 때까지 기다리는 것이 좋습니다. 그것은 'ZZZZZ'로 앰퍼샌드를 대체하기 위해 참조하는 페이지의 URL을 munges,
_ 그걸 붙이면 작동하지 않습니다 ._ 정확히 작동하지 않는 것은 무엇입니까? "그녀가 말한 것은 그게 내 마음 속에 떠오르는 이유"입니다. – epascarello
하하, 고마워. 방금 T.J.의 게시물에 아래에 설명을 올렸습니다. 창문 안에 넣는 데 문제가있어.로드. – RyanPitts