[英]kineticjs “cannot call method 'appendChild' of undefined”
[英]cannot call method appendChild of undefined
當我在javascript(flickrshow-7.1.js)的innerHtml內插入aa href標記以插入圖像鏈接時,會出現此錯誤。 使用flickrshow javascript從flickr帳戶中提取圖像,並以幻燈片形式顯示在網站上。
a.onLoadWindow = function() {
a.elements.target = typeof a.elements.target === "string" ? document.getElementById(a.elements.target) : a.elements.target;
a.elements.target.innerHTML = '<a href="http://www.google.com"><div class="flickrshow-container" style="background:transparent;height:' + a.elements.target.offsetHeight + "px;margin:0;overflow:hidden;padding:0;position:relative;width:" + a.elements.target.offsetWidth + 'px"></div></a>';
undefined
錯誤表示您要在其上調用appendChild
的javascript變量沒有值。 您需要修復初始化,以便它具有可調用appendChild
的值
<p id="parent"></p>
...
var newNode = document.createElement("li");
var parent;
parent.appendChild(newNode); // Error!!! What is parent?
parent = document.getElementById("parent");
parent.appendChild(newNode);
img元素沒有innerHTML,並且不能將子節點附加到img。 而是將圖像換成a元素。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.