티스토리 툴바



'DOMContentLoaded'에 해당되는 글 1건

  1. 2008/10/12 emulating DOMContentLoaded

emulating DOMContentLoaded

(function () {
    var loadCallBack = function () {
        if (document.domParsed) return;
        document.domParsed = true;
        Event.readyCache.each(function (fn) { fn.apply(document); });
        Event.readyCache = null;
        loadCallBack = null;
    };
    if (Browser.isWebKit || (Browser.isOpera && window.opera.version() < 9)) {
        (function () {
            if (/loaded|complete/.test(document.readyState)) return $stop;
        }).interval(1, loadCallBack);
    }
    else if (Browser.isIE) {
        var temp = document.createElement("div");
        (function () {
            try {
                temp.doScroll('left');
                temp = null;
                return $stop;
            }
            catch (ex) {}
        }).interval(1, loadCallBack);
    }
    else {
        document.addEventListener("DOMContentLoaded", loadCallBack, false);
    }
})();
윈도우의 경우 htc가 연결된 경우 (ex : IE6 png Hack) 모든 htc 동작이 끝난 후에 이벤트가 발생하게 된다.
이 경우
스타일에
body {behavior: url(/js/loaded.htc);}

를 선 언해 주고
loaded.htc 파일은 다음과 같이 작성해주면 된다.
<public:component lightweight="true">
    <public:attach event="ondocumentready" for="window" onEvent="loadCallBack()" />
</public:component>
htc를 사용할 경우 사용하면 된다.

dean.edwards.name 에서 참조하였음.


Comment 0 Trackback 0

Trackback : http://happyhoon.tistory.com/trackback/16 관련글 쓰기

Top

prev 1 next