zoukankan      html  css  js  c++  java
  • 判断一个脚本已经加载完毕的方法

    export const appendScriptReady = (url, onReadyCallback) => {
      const targetScript = document.createElement('script')
      targetScript.type = 'text/javascript'
      if (targetScript.readyState) { // IE 6,7,8
        targetScript.onreadystatechange = () => {
          if (targetScript.readyState === 'loaded' ||
            targetScript.readyState === 'complete') {
            targetScript.onreadystatechange = null
            onReadyCallback()
          }
        }
      } else { // Not IE
        targetScript.onload = () => {
          onReadyCallback()
        }
      }
    
      targetScript.src = url
      document.head.appendChild(targetScript)
    }
  • 相关阅读:
    css3线性渐变
    php的%s
    面向对象
    excel导入导出
    保存Excel
    保存word
    图片预览
    验证日期输入格式
    级联菜单
    中级前端知识点提要
  • 原文地址:https://www.cnblogs.com/weilantiankong/p/9443057.html
Copyright © 2011-2022 走看看