时间:2021-05-18
复制代码 代码如下:
prowin.js
/**
*@authorldgmc
*/
functionPopWin(id,width,title){
this.id=id;
this.width=width;
this.title=title;
this.createIns=function(){
varins=document.createElement("div");
ins.className="popWin";
ins.id=this.id;
ins.style.width=this.width+'px';
returnins;
};
this.items=newArray();
this.instance=this.createIns();
this.init=function(){
this.addTitle(this.title);
document.body.appendChild(this.instance);
}
this.addTitle=function(title){
vartitleDiv=document.createElement("div");
titleDiv.className="title";
vartitleText=document.createTextNode(title);
titleDiv.appendChild(titleText);
this.instance.appendChild(titleDiv);
}
this.addItem=function(id,title){
this.items[id]={};
this.items[id]["title"]=ldg.common.setClassName("div","itemTitle");
this.items[id]["title"].appendChild(document.createTextNode(title));
this.items[id]["content"]=ldg.common.setClassName("div","itemContent");
this.items[id]["title"].id=id;
ldg.event.addEvent(this.items[id]["title"],"mouseover",this.mouseover.bindAsEventListener(this))
ldg.event.addEvent(this.items[id]["title"],"mouseout",this.mouseout.bindAsEventListener(this));
ldg.event.addEvent(this.items[id]["title"],"click",this.click.bindAsEventListener(this));
this.instance.appendChild(this.items[id]["title"]);
this.instance.appendChild(this.items[id]["content"]);
}
this.addItemContent=function(parentId,imgUri,cssUri,isLast){
varitemDiv=ldg.common.setClassName("div","item");
varitema=document.createElement("a");
itema.href="#";
varitemImg=document.createElement("img");
itemImg.src=imgUri;
itemImg.css=cssUri;
ldg.event.addEvent(itemImg,"click",this.changeLink.bindAsEventListener(this));
itema.appendChild(itemImg);
itemDiv.appendChild(itema);
this.items[parentId]["content"].appendChild(itemDiv);
if(isLast){
this.items[parentId]["content"].appendChild(document.createElement("br"));
}
}
this.changeLink=function(e){
vareObj=e.srcElement||e.target;
varlink=document.getElementsByTagName("link");
link[1].href=eObj.css;
}
this.mouseover=function(e){
vareObj=e.srcElement||e.target;
eObj.style.backgroundColor="#e5e5e5";
}
this.mouseout=function(e){
vareObj=e.srcElement||e.target;
eObj.style.backgroundColor="#EEEEEE";
}
this.click=function(e){
vareObj=e.srcElement||e.target;
varitem=this.items[eObj.id]["content"];
item.style.display=="block"?item.style.display="none":item.style.display="block";
}
this.init();
复制代码 代码如下:
ldg.js
varldg=window.ldg||{}
Array.prototype.append=function(item){
this[this.length]=item
}
Function.prototype.bindAsEventListener=function(obj){
var_method=this;
returnfunction(event){
return_method.call(obj,event||window.event);
}
}
ldg.event={
addEvent:function(obj,evType,fun){
if(obj.addEventListener){
obj.addEventListener(evType,fun,false);
returntrue;
}elseif(obj.attachEvent){
obj.attachEvent("on"+evType,fun);
returntrue;
}else{returnfalse}
}
}
ldg.common={
$:function(id){
returndocument.getElementById(id);
},
setClassName:function(eleType,className){
varelement=document.createElement(eleType)
element.className=className;
returnelement;
}
}
复制代码 代码如下:
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<title>testBlog</title>
<linkrel=stylesheettype=text/csshref="css/window.css">
<linkrel=stylesheettype=text/csshref="css/bg.css">
<scriptsrc="js/prpwin.js"></script>
<scriptsrc="js/ldg.js"></script>
<script>
window.onload=function(){
varpop=newPopWin(1,440,"标题");
pop.addItem(1,"默认主题");
pop.addItem(2,"2222");
pop.addItem(3,"3333");
pop.addItem(4,"4444");
pop.addItemContent(1,"images/1.gif","css/bg2.css");
pop.addItemContent(1,"images/2.gif","css/bg3.css");
pop.addItemContent(1,"images/3.gif","css/bg4.css");
pop.addItemContent(1,"images/4.gif","css/bg5.css");
pop.addItemContent(1,"images/5.gif","css/bg6.css");
pop.addItemContent(1,"images/1.gif","css/bg7.css");
pop.addItemContent(1,"images/2.gif","css/bg8.css");
pop.addItemContent(1,"images/3.gif","css/bg9.css");
pop.addItemContent(1,"images/4.gif","css/bg0.css");
pop.addItemContent(1,"images/5.gif","css/bg4.css");
pop.addItemContent(1,"images/6.gif","css/bg2.css",true);
pop.addItemContent(2,"images/7.gif","css/bg8.css");
pop.addItemContent(2,"images/8.gif","css/bg6.css");
pop.addItemContent(2,"images/9.gif","css/bg3.css");
pop.addItemContent(2,"images/10.gif","css/bg2.css");
pop.addItemContent(2,"images/11.gif","css/bg6.css");
pop.addItemContent(2,"images/12.gif","css/bg4.css",true);
pop.addItemContent(3,"images/13.gif","css/bg9.css");
pop.addItemContent(3,"images/14.gif","css/bg1.css");
pop.addItemContent(3,"images/15.gif","css/bg7.css",true);
pop.addItemContent(4,"images/4.gif","css/bg9.css");
pop.addItemContent(4,"images/5.gif","css/bg3.css");
pop.addItemContent(4,"images/1.gif","css/bg5.css");
pop.addItemContent(4,"images/2.gif","css/bg2.css");
pop.addItemContent(4,"images/3.gif","css/bg3.css");
pop.addItemContent(4,"images/4.gif","css/bg0.css");
pop.addItemContent(4,"images/5.gif","css/bg7.css");
pop.addItemContent(4,"images/1.gif","css/bg4.css");
pop.addItemContent(4,"images/2.gif","css/bg3.css");
pop.addItemContent(4,"images/4.gif","css/bg7.css");
pop.addItemContent(4,"images/5.gif","css/bg1.css");
pop.addItemContent(4,"images/4.gif","css/bg1.css",true);
}
</script>
</head>
<body>
</body>
</html>
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例讲述了JS实现网页顶部向下滑出的全国城市切换导航效果。分享给大家供大家参考。具体如下:这是一款JS版网页顶部向下滑出的城市切换导航,仿sohu团购网页顶
AdobeAcrobat想要更换页面,该怎么替换页面呢?下面我们就来看看详细的教程。软件名称:AdobeAcrobatProDCv2020.012.20048中
本文实例讲述了JS实现仿Windows经典风格的选项卡Tab切换代码。分享给大家供大家参考,具体如下:这款仿Windows风格的选项卡,带有灰色的立体感,示例内
淘宝超级店长是一个方便的工具,可以定制自己的页面,但是有些运营同学不知道如何更换页面。因此,我收集了相关内容。让我们来看看淘宝超级店长如何更换页面的具体步骤1、
有时拿到一份PDF文档时,需要在文档中添加页面、更换页面顺序、添加空白页面等,ABBYYPDFTransformer+软件可以实现这一点。软件名称:PDF格式转