簡體   English   中英

Firefox和Chrome不會在innerHTML中顯示圖像

[英]Firefox & Chrome don't display image in innerHTML

我有一個相當簡單的功能,隱藏一些用於收集一些信息的div,然后顯示更新消息....

function updatePleaseWaitingPane() {

    document.getElementById('formDiv').style.display = "none";
    document.getElementById('furtherQuestions').style.display = "none";
    var newdiv = document.createElement('div');
    newdiv.setAttribute('id', 'PleaseWaitDiv');
    newdiv.innerHTML = "<h2>Please wait</h2><br/><br/><br/><br/><img src=\"http://www.myurl.com/images/pleaseWait.gif\" alt=\"Please wait\" width=\"600\" height=\"54\"><br/><br/><br/><br/>Thanks for your input. Now let us get you some answers";
    document.getElementById('Content').appendChild(newdiv);
}

它一切正常,很簡單,但是我注入的圖像似乎並沒有加載到Firefox的Chrome中,但它在IE中卻有效嗎? 我檢查了URL,在Firebug中檢查元素時,圖像顯示為預覽,因此URL正確。 任何人的想法?

IE會將document.getElementById('Content')與不同的id="content"匹配,而Chrome則不會,確定ID是否正確?

嘗試關閉圖片代碼

<img src="/watever" />

^^注意關閉角括號前的斜線

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM