历时八天,终于弄完了,此代码堪称完美,无懈可击,哈哈哈,图片库最终版js文件
来源:互联网 发布:python数据挖掘 pdf 编辑:程序博客网 时间:2024/04/30 11:21
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].onclick=function(){return !showpic(this);}
//links[i].onkeypress=links[i].onclick;残疾人可用用tab和enter产生问题过多
}
}
function addloadevent(func)//万能函数,解决数量特别多的时候window.onload;
{
var oldonload=window.onload;
if(typeof window.onload!='function')
{
window.onload=func;
}else
{
window.onload=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].onclick=function(){return !showpic(this);}
//links[i].onkeypress=links[i].onclick;残疾人可用用tab和enter产生问题过多
}
}
function addloadevent(func)//万能函数,解决数量特别多的时候window.onload;
{
var oldonload=window.onload;
if(typeof window.onload!='function')
{
window.onload=func;
}else
{
window.onload=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);
0 0
- 历时八天,终于弄完了,此代码堪称完美,无懈可击,哈哈哈,图片库最终版js文件
- 完美代码,让你的代码无懈可击
- js完美运动框架最终版
- 完美代码(让你编出无懈可击的完美代码)
- 终于弄完了NTFS
- 终于把代码重写完了
- 终于完了~~
- 终于把所有的购房合同文件签完了
- 终于快忙完了
- 终于签完了
- PMP考试终于完了
- 考试终于完了
- 终于折腾完了
- 终于考完了
- 终于搬完了
- 终于考完了
- 终于考完了
- 终于开发完了。
- 【Maven】解决linux下安装maven update-alternative --display mvn链接层数过多
- 操作系统的特性
- Spark入门遇见的问题1
- 朴素贝叶斯 python
- HDU 1054 Strategic Game By Assassin
- 历时八天,终于弄完了,此代码堪称完美,无懈可击,哈哈哈,图片库最终版js文件
- ants
- 数据库系列:索引总结
- CSS旋转图片
- springmvc postman
- D3D11教程八之FontEngine(字体实现)
- QPainter的使用(画国旗)
- 43. Multiply Strings
- 切饼