function showpic(whichpic)//假设过多
{
if(!document.getElementById("placeholder"))return false;
var source=whichpic.getAttribute("href");
var place=document.getElementById("placeholder");
if(placeholder.nodeName!="IMG")return false;
place.setAttribute("src",source);//后面的值赋给前面
if(document.getElementById("description"))
{
var text=whichpic.getAttribute("title")?whichpic.getAttribute("title"):" ";/*三目运算符*/
var descript=document.getElementById("description");
if(descript.firstChild.nodeType==3)
{
descript.firstChild.nodeValue=text;
}
}
return true;
}
function prepargallery()//分离javascript
{
if(!document.getElementsByTagName)return false;
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].οnclick=function(){return !showpic(this);}
//links[i].οnkeypress=links[i].onclick;残疾人可用用tab和enter产生问题过多
}
}
function addloadevent(func)//万能函数,解决数量特别多的时候window.onload;
{
var oldοnlοad=window.onload;
if(typeof window.onload!='function')
{
window.οnlοad=func;
}else
{
window.οnlοad=function(){oldonload();func();}
}
}
function prepareplaceholder()
{
if(!document.createElement)return false;
if(!document.createTextNode)return false;
if(!document.getElementById)return false;
if(!document.getElementById("imagegallery"))return false;
var placeho=document.createElement("img");
placeho.setAttribute("id","placeholder");
placeho.setAttribute("src","img/287080.jpg");
var descript=document.createElement("p");
descript.setAttribute("id","description");
var desctext=document.createTextNode("秋天的树林");
descript.appendChild(desctext);
var gallery=document.getElementById("imagegallery");
insertafter(placeho,gallery);
insertafter(descript,placeho);
}
function insertafter(newelement,targetelement)
{
var parent=targetelement.parentNode;
if (parent.lastChild==targetelement)
{
parent.appendChild(newelement);
}
else
{
parent.insertBefore(newelement,targetelement.nextsibling);
}
}
addloadevent(prepareplaceholder);
addloadevent(prepargallery);
{
if(!document.getElementById("placeholder"))return false;
var source=whichpic.getAttribute("href");
var place=document.getElementById("placeholder");
if(placeholder.nodeName!="IMG")return false;
place.setAttribute("src",source);//后面的值赋给前面
if(document.getElementById("description"))
{
var text=whichpic.getAttribute("title")?whichpic.getAttribute("title"):" ";/*三目运算符*/
var descript=document.getElementById("description");
if(descript.firstChild.nodeType==3)
{
descript.firstChild.nodeValue=text;
}
}
return true;
}
function prepargallery()//分离javascript
{
if(!document.getElementsByTagName)return false;
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].οnclick=function(){return !showpic(this);}
//links[i].οnkeypress=links[i].onclick;残疾人可用用tab和enter产生问题过多
}
}
function addloadevent(func)//万能函数,解决数量特别多的时候window.onload;
{
var oldοnlοad=window.onload;
if(typeof window.onload!='function')
{
window.οnlοad=func;
}else
{
window.οnlοad=function(){oldonload();func();}
}
}
function prepareplaceholder()
{
if(!document.createElement)return false;
if(!document.createTextNode)return false;
if(!document.getElementById)return false;
if(!document.getElementById("imagegallery"))return false;
var placeho=document.createElement("img");
placeho.setAttribute("id","placeholder");
placeho.setAttribute("src","img/287080.jpg");
var descript=document.createElement("p");
descript.setAttribute("id","description");
var desctext=document.createTextNode("秋天的树林");
descript.appendChild(desctext);
var gallery=document.getElementById("imagegallery");
insertafter(placeho,gallery);
insertafter(descript,placeho);
}
function insertafter(newelement,targetelement)
{
var parent=targetelement.parentNode;
if (parent.lastChild==targetelement)
{
parent.appendChild(newelement);
}
else
{
parent.insertBefore(newelement,targetelement.nextsibling);
}
}
addloadevent(prepareplaceholder);
addloadevent(prepargallery);