window OnLoad Event setInterval Redirect example

window OnLoad Event도 특정 엘리먼트가 없는 경우 특정 사이트로 이동하는 방법에 대한 예시입니다. 보통 블로그 테마 프리 템플릿으로 제공하는 특정 부분을 없애면 이동시키도록 장치해 놓는 경우에 사용할 수 있습니다. setInterval 로 반복하여 엘리먼트 여부를 체크하도록 합니다. 구글 블로그(블로거, 블로그스팟) 테마 중에 푸터를 삭제하는 경우 특정 사이트로 리디렉션 되는 경우가 있는데 해당과 같은 기법을 사용하는 경우가 있습니다.

window["onload"] = function() {
    var a = document[getElementById](elementId);
    var b = "https://~.com";
    var t = 2000;
    var tt = "Title";
    var i = "Inner HTML";
    setInterval(function() {
        if (a == null) {
            window["location"]["href"] = b
        };
        if ($(a)["css"]("visibility") == "hidden") {
            document["location"]["href"] = b
        };
        if ($(a)["css"]("visibility") == "collapse") {
            document["location"]["href"] = b
        };
        if ($(a)["css"]("display") == "none") {
            document["location"]["href"] = b
        };
    }, t);
    a[setAttribute]("href", b);
    a[setAttribute]("rel", "dofollow");
    a[setAttribute]("title", tt);
    a[innerHTML] = i;
}

댓글