设为首页   加入最爱           最新更新:全方位英文文章资料库
 
资料坊搜索: 标题 全文     
“智慧型”网页制作技巧
   首页>>YesizeCOM>>电脑技能坊>>Javascript>>正文       
 
广告招租,e-mail:yesize@hotmail.com

广告招租,e-mail:yesize@hotmail.com

  人们都希望自己的主页生动活泼,并且多一些与访问者的交互。下面的小技巧是否能让你感到自己的网页多了几分色彩呢?
 1.来访者访问次数的记录
  一位来访者看到我能统计他访问我的主页的次数时,非常惊讶,他在留言簿里问我是不是发了黑客程序给他,其实就是下面这段小程序(见程序1)。
  <script
  LANGUAGE=JavaScript>
  <!--
  var caution = false
  function setCookie(name,value,expires,path,domain,secure) {
  var curCookie=name+=+escape(value)+
  ((expires)?;expires=+expires.toGMTString():)+((path)?;path=+path:)+ domain)?;domain=+domain:)+((secure)?;secure:) 
  if (!caution || (name+=+escape(value)).length<=4000)
  document.cookie=curCookie
  else
  if (confirm(Cookie exceeds 4KB and will be cut!))
  document.cookie=curCookie
  }
 function getCookie(name) {
  var prefix = name + =
  var cookieStartIndex=document.cookie.indexOf(prefix)
  if (cookieStartIndex == -1)
  return null
  var cookieEndIndex=document.cookie.indexOf(;,cookieStartIndex+prefix.length)
  if (cookieEndIndex == -1)
  cookieEndIndex=document.cookie.length
  return unescape(document.cookie.substring(cookieStartIndex+prefix.length,
 cookieEndIndex))
 }
  function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
  document.cookie=name+=+((path)?;path=+path:)+((domain)?;domain=+domain:)+;expires=Thu,01-Jan-70 00:00:01 GMT
  }
  }
  function fixDate(date) {
  var base = new Date(0)
  var skew = base.getTime()
  if (skew > 0)
  date.setTime(date.getTime()-skew)
  }
  var now = new Date()
  fixDate(now)
 now.setTime(now.getTime()+365*24*60*60*1000)
  var visits = getCookie(counter)
  if (!visits)
  visits = 1
  else
  visits = parseInt(visits) + 1
  setCookie(counter, visits, now)
  document.write(我想您是第+visits+次来这儿了!很高兴又见到你噢^_^!)
  // -->
  </script>
  (程序1)
  2.可以根据时间变化的欢迎词
  下面这段小程序能够根据访问者来访的时间的不同而致以不同的欢迎词(见程序2)。
  <script
  language=Javascript>
 <!-- Hiding
 var now = new Date()
 var year=now.getYear()
 var month=now.getMonth()+1;
 var date= now.getDate()
 var time = now.getHours()
  if (time>=0)
  {var hello=你真是个夜猫子!这么晚了还在闲逛,你知道吗?}
  if (time>=6)
  {var hello=现在还是挺早的,}
  if (time>=9)
  {var hello=小心老板哦,}
  if (time>=12)
  {var hello=中午好呀!}
  if (time>13)
  {var hello=中午睡觉了吗?}
  if (time>=18)
  {var hello=吃晚饭了吗?}
  if time>19)
  {var hello=怎么没看电视?}
  if (time>23)
  {var hello=已经很晚了,还不去睡觉?你知道不?}
  var hour1=(now.getHours() >=10)?:0
  var m2=(now.getMinutes()>=10)?:0
  var t=(now.getHours()>12)?now.getHours()-12:now.getHours()
  var r2 = (t >= 10) ?  : 
  var color=(now.getSeconds()%2==0)?ffff80:00000f
  dcument.write(<font color=\#,color,\>,hello,现在是北京时间:19,year,年,month,月,date,日,,hour1,now.getHours(),点,m2,now.getMinutes(),分,((now.getSeconds()<10)?0:)+now.getSeconds(),秒了,</font>)
 timerRunning=true
 //end hiding contents -->
 </script>
  (程序2)
 看到这么亲切的问候词,你的访问者一定会多一份对你网页的关心和呵护。

 3.访问者所使用的浏览器版本的确定
 <script>
 document.write(您现在用的是+navigator.appName++navigator.appVersion+版的浏览器,我猜对了吗?开个玩笑,无论对错,真的很希望您能经常来呦!)
 </script>
 把这些小程序加到你的网页中试试看,有什么问题可以写信告诉我,地址是 doggy007@188.net。

上一篇:随机显示图片 下一篇:教你制作多彩的弹出式说明窗口

版权说明:作品来源于网上,版权归作者所有,如果无意中侵犯了您的版权,请来信告知,本站将在3个工作日内删除。yesize@hotmail.com
  热门小游戏分类 
射击小游戏 连连看小游戏
台球小游戏 成人小游戏
CS小游戏 化妆小游戏
赛车小游戏 休闲小游戏
篮球小游戏 换装小游戏
儿童小游戏 牛牛小游戏
麻将小游戏 冒险小游戏
美媚小游戏 益智小游戏
体育小游戏  
Society Recreation & Sports
Travel & Leisure Communications
Vehicles Computers
Fashion Arts & Entertainment
Reference & Education Disease & Illness
Writing & Speaking Politics
Product Reviews Food & Beverage
Finance Internet Business
Self Improvement Home & Family
Health & Fitness Business
最新更新内容
警惕“公务员报考热”背
公务员考试不是丈母娘考
一名新公务员的自白:我
公务员考脑筋急转弯与挂
北努斗:2006行政能力测
大讨论:06行测BT题目大
过来人回忆:当年,我也
一家之言:公务员热折射
公务员考试申论要是有正
数十万大学生走进公务员
      粤ICP备05005424         Copyright ©2000 - 2004 Yesize.COM