동적 불 러 오기 js

1327 단어 js


<script type="text/javascript">
  var loadJS = function (params) {
    var head = document.getElementsByTagName("head")[0];

    var script = document.createElement('script');

    script.onload = script.onreadystatechange = script.onerror = function () {
      if (script && script.readyState && /^(?!(?:loaded|complete)$)/.test(script.readyState)) return;

      script.onload = script.onreadystatechange = script.onerror = null;
      script.src = '';
      script.parentNode.removeChild(script);
      script = null;

      if (typeof params.callback == "function")
        params.callback();
    };
    script.charset = params.charset || document.charset || document.characterSet || 'utf-8';
    script.src = params.src;

    try {
      head.appendChild(script);
    } catch (exp) {
    }
  };
  (function(oWin) {
    if ((!oWin.parent && !oWin.dialogArguments) ||(oWin.parent && !oWin.parent.dialogArguments) ) {
      loadJS({src: "../../js/cookie.js", charset:"utf-8"});
    }
  })(window);
</script>


좋은 웹페이지 즐겨찾기