2017-04-23 17 views
1

我試圖使用alertifyjs(https://alertifyjs.org/)庫。alertify.js TypeError?

在代碼預覽網站(如codepen或在此處的stackoverflow)中測試警報,警報正常工作。

然而,當我在我的網站上使用完全相同的代碼與codepreview的只是代碼,我得到一個錯誤在我的控制檯

Uncaught TypeError: Cannot read property 'appendChild' of null

我不知道我錯過了什麼。

還可以測試在這裏看到的錯誤:https://www.mercomods.com/testpage-2/ (IM要去保持這種向上翻頁)

function myFunction() { 
 
    alertify.log("Standard log message"); 
 
}
<script src="https://www.mercomods.com/wp-content/themes/newave-theme/alertify.js-master/src/js/alertify.js"></script> 
 
<button onclick="myFunction()">Alert</button>

回答

0

的alertify腳本標籤應該是在身體的結束,因爲它加載時將變量初始化爲document.body - 如果初始化過早,則該值爲空