我跟着Jeremy Keith的书“DOM Scripting”,我试图让一个小图片库在Internet Explorer 6/7中正确呈现,我碰到了一堵墙。Internet Explorer Javascript Image问题
我有4个缩略图使用下面的代码点击时负载的占位符:
function showPic(whichpic) {
if (!document.getElementById("placeholder")) return true;
var source = whichpic.getAttribute("href");
var placeholder = document.getElementById("placeholder");
placeholder.setAttribute("src",source);
if (!document.getElementById("description")) return false;
var text = whichpic.getAttribute("title") ? whichpic.getAttribute("title") : "";
var description = document.getElementById("description");
if (description.firstChild.nodeType == 3) {
description.firstChild.nodeValue = text;
}
return false;
}
我的占位符插入使用createElement("img")
的页面,但是当我点击缩略图图像压缩规模它替换的占位符。
function preparePlaceholder() {
if(!document.createElement) return false;
if(!document.createTextNode) return false;
if(!document.getElementById) return false;
if(!document.getElementById("imagegallery")) return false;
var placeholder = document.createElement("img");
placeholder.setAttribute("id","placeholder");
placeholder.setAttribute("src","images/placeholder.gif");
placeholder.setAttribute("alt","Gallery Placeholder");
var description = document.createElement("p");
description.setAttribute("id","description");
var desctext = document.createTextNode("Choose an image");
description.appendChild(desctext);
var gallery = document.getElementById("imagegallery");
insertAfter(placeholder,gallery);
insertAfter(description,placeholder);
}
因此,如下图所示的结果是扭曲的图像:
直播网站在这里:http://anarchist.webuda.com/
的Javascript这里:http://pastebin.com/kaAhjdqk HTML浏览:这里http://pastebin.com/Dm5p2Dj6 CSS :http://pastebin.com/yiVPiQZe
怎么样的CSS? – 2010-07-29 06:25:00
加入:http://pastebin.com/yiVPiQZe – Ash 2010-07-29 06:27:59