我的程序阻止默认程序失败了 大神帮我看看哪里出错了
window.onload=function(){preparegallery();
showpic();
}
function showpic(whichpic){
if (!document.getElementById("placeh")) return false;
var source = whichpic.getAttribute("href");
var placeh = document.getElementById("placeh");
if (placeh.nodeName != "IMG") return false;
placeh.setAttribute("src", source);
if (document.getElementById("description"))
{
var text = whichpic.getAttribute("title") ? whichpic.getAttribute("title"):"";
var description = document.getElementById("description");
if(description.firstChild.nodeType == 3)
{
description.firstChild.nodeValue = text;
}
}
return true;
}
function preparegallery(){
if(!document.getElementsByTagName) return falae;
if(!document.getElementById) return false;
if(!document.getElementById("imagegallery")) return false;
var gallery=document.getElementById("imagegallery");
var links=gallery.getElementsByTagName("a");
for(var i=0;i<links.length;i++){
links[i].onclick=function(){
return !showpic(this);
}
}
}
阻止点击链接的默认事件没有成功 哪里错了