代码之家  ›  专栏  ›  技术社区  ›  miushock

如何从DOM错误事件中获取详细消息

  •  3
  • miushock  · 技术社区  · 7 年前

    我试图理解Chrome对html导入的实现,例如

     <link id="test_component" rel="import" href="http://localhost:8888/fail.html" onerror="handler(event)">
    

    MDN

    1 回复  |  直到 7 年前
        1
  •  1
  •   Supersharp    7 年前

    如果触发了错误事件处理程序,您可以 重播 使用的请求 XMLHttpRequest fetch

    function handler(event) 
    {
        fetch(event.target.href)
            .then( resp => console.info(resp.status) )
            .catch( err => console.log(err) )
    }