未捕获的TypeError:无法设置属性' innerHTML'在window.onload中为null

时间:2017-12-22 09:53:31

标签: javascript

 window.onload=function(){
    document.getElementById("acwidget").innerHTML = 'Text';
    //document.getElementById("acwidget");
    var acwidget = document.getElementById("acwidget");
    document.querySelector(".header").addEventListener("click", function(){
     //some come
    });

    (function() {
        var mycsswdg = document.createElement("link");
        mycsswdg.setAttribute("rel", "stylesheet");
        mycsswdg.setAttribute("type", "text/css");
        mycsswdg.setAttribute("href", "mystyle.css");
        //style bootstrap
        var mycssbts = document.createElement("link");
        mycssbts.setAttribute("rel", "stylesheet");
        mycssbts.setAttribute("type", "text/css");
        mycssbts.setAttribute("href", "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css");
        // Inseriamo il CSS nell"head
        document.getElementsByTagName("head")[0].appendChild(mycssbts);
        document.getElementsByTagName("head")[0].appendChild(mycsswdg);
    })(); // Chiamiamo subito la nostra funzione anonima

}//]]> **strong text**

我收到此错误"未捕获的TypeError:无法设置属性' innerHTML'在window.onload"中为null,我在哪里错了?

0 个答案:

没有答案