DDscorpio的专栏

*掺杂着影视作品的Coding人生

用户操作
[即时聊天] [发私信] [加为好友]
ddscorpioID:ddscorpio
22843次访问,排名5425(1),好友0人,关注者0人。
ddscorpio的文章
原创 48 篇
翻译 0 篇
转载 1 篇
评论 45 篇
ddscorpio的公告
最近评论
algcfx:Wow gold
algcfx:Wow gold
algcfx:Wow gold
algcfx:Wow gold
fsy123456accp:晕 不是asp.net的啊
文章分类
收藏
相册
Chairman Mao
CHE Guevara
LENNON
life
MonaLisa
My pics
photos at home
THE PROFESSIONAL LEON
阿佩2006生日的这一天
已沉淀的岁月
My Fellows' Blog
paper
妹's BLOG(RSS)
小邹邹
小鸿
小黄同学
暴蓝(RSS)
石哥(RSS)
老子
老驴
阿佩牛
阿佩牛的BLOG(RSS)
存档
软件项目交易
订阅我的博客
XML聚合  FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
订阅到BlogLines
订阅到Yahoo
订阅到GouGou
订阅到飞鸽
订阅到Rojo
订阅到newsgator
订阅到netvibes

原创 DOM小试牛刀收藏

新一篇: 8天时间的小安慰 | 旧一篇: 祝福的游戏。。。。。。。。。

最近做个小项目,用到了DOM进行动态写标签。

JS:

function addLoadEvent(func){
 var oldonload=window.onload;//获取已经存在的window.onload事件

if (typeof window.onload!='function'){
  window.onload=func;//如果window.onload没有事件,那就将func赋给它
  }else {
   window.onload=function(){
    oldonload();
    func();//否则将func加到window.onload所有事件的末尾
   }
 }
}

function insertCopyright(){
 var parentEle=document.getElementsByTagName("body")[0].lastChild;//获取BODY的最后一个节点元素
 if (parentEle){
  createEles(parentEle);//如果这个元素存在,则调用createEles函数
 }
 else return false;
}
function createEles(parent){
 var textFirst=document.createElement("p");
 var textSecond=document.createElement("p");
 var textThird=document.createElement("p");
 var textFourth=document.createElement("a");
 var textE1=document.createTextNode("XXLJFLJALJFLSJFLJ公司");
 var textE2=document.createTextNode("联系电话:86-sfsfsffsf");
 var textE3=document.createTextNode("技术支持:");
 var textE4=document.createTextNode(www.abc.com);
 
 parent.appendChild(textFirst);
 parent.appendChild(textSecond);
 parent.appendChild(textThird);
 
 textFirst.appendChild(textE1);
 textSecond.appendChild(textE2);
 textThird.appendChild(textE3);
 textThird.appendChild(textFourth);
 textFourth.appendChild(textE4);
 textFourth.href=http://www.abc.com;
}

addLoadEvent(insertCopyright);

-----------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>某某某</title>
<script  type="text/javascript" src="scripts/insertCopyright.js"></script>
</head>

<body>
  <div id="content_right_container">
  <div id="content_right_first">
   <ul>
     <li class="proList"><a href="products/jtie.html"><img src="images/index_p_1.jpg" /></a></li>
     <li class="proList"><a href="products/pjian.html"><img src="images/index_p_2.jpg" /></a></li>
     <li class="proList"><a href="products/yanglizi.html"><img src="images/index_p_3.jpg" /></a></li>
     <li class="proList"><a href="products/gyjxwsn.html"><img src="images/index_p_4.jpg" /></a></li>
     <li class="proList"><a href="products/flzi.html"><img src="images/index_p_5.jpg" /></a></li>
   </ul>
  </div>
  
  <div id="content_right_second">
   <ul>
     <li class="proList"><a href="products/jhyhl.html"><img src="images/index_p_6.jpg" /></a></li>
     <li class="proList"><a href="products/mfan.html"><img src="images/index_p_7.jpg" /></a></li>
     <li class="proList"><a href="products/bxxan.html"><img src="images/index_p_8.jpg" /></a></li>
     <li class="proList"><a href="products/ylzi.html"><img src="images/index_p_9.jpg" /></a></li>
     <li class="proList"><a href="products/spjxwsn.html"><img src="images/index_p_10.jpg"/></a></li>
   </ul>
  </div>
  </div>
   </div>
 </div>
 
 <div id="bottom">
 </div>
</body>
</html>

 

发表于 @ 2007年08月29日 00:22:00|评论(loading...)|编辑

新一篇: 8天时间的小安慰 | 旧一篇: 祝福的游戏。。。。。。。。。

评论

#你上铺的大哥 发表于2007-09-04 21:46:26  IP: 219.159.240.*
再写这些下次就不来看了
打击人啊!
#啊佩  发表于2007-09-06 11:42:12  IP: 116.253.26.*
朱在学习 ,朱在长大 !~
发表评论  


登录
Csdn Blog version 3.1a
Copyright © ddscorpio