火狐浏览器Chrome 不显示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 是正确的。有人有什么想法吗?
I've got a rather simple function that hides some divs used to collect some info and then shows an update message....
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);
}
it all works fine, it is simple, however the image I've injected doesn't seem to load in Chrome of Firefox, but it does in IE? I've checked the URL and when inspecting the element in Firebug the image is displayed with a preview so the URL is correct. Any ideas anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IE 会将
document.getElementById('Content')
与大小写不同的id="content"
进行匹配,而 Chrome 则不会,确定 ID 正确吗?IE will match
document.getElementById('Content')
against the differently casedid="content"
whereas Chrome will not, sure the ID is correct?尝试关闭图像标签
^^ 注意右尖括号之前的斜线
Try closing the image tag
^^ note the slash before the closing angle bracket