首页 > 办公 > FrontPage > 正文

实现网页状态栏特效全攻略

2024-09-12 15:14:19
字体:
来源:转载
供稿:网友

    在上网时我们注意往往是网站页面内容,而状态栏不会被人太多注意,如果我们给页面的状态栏加一些特效,肯定会使你的网站增添一道风景,下面就给大家介绍7种常见的状态栏特效的javascript代码。

特效一:滚动显示

第一步:把如下代码加入〈head〉区域中

〈script language="javascript"〉
  〈!--
  function scrollit(seed) {
  var m1 = "hi:你 好! ";
  var m2 = "欢迎访问tom科技";
  var m3 = "请多提意见,谢 谢! ";
  var m4 = "欢迎您下次再来! ";
  var m5 = "http://tech.tom.com ";
  var msg=m1+m2+m3+m4+m5;
  var out = " ";
  var c = 1;
  if (seed > 100) {
  seed--;
  cmd="scrollit("+seed+")";
  timertwo=window.settimeout(cmd,100);
  }
  else if (seed <= 100 && seed > 0) {
  for (c=0 ; c < seed ; c++) {
  out+=" ";
  }
  out+=msg;
  seed--;
  window.status=out;
  cmd="scrollit("+seed+")";
  timertwo=window.settimeout(cmd,100);
  }
  else if (seed <= 0) {
  if (-seed < msg.length) {
  out+=msg.substring(-seed,msg.length);
  seed--;
  window.status=out;
  cmd="scrollit("+seed+")";
  timertwo=window.settimeout(cmd,100);
  }
  else {
  window.status=" ";
  timertwo=window.settimeout("scrollit(100)",75);
  }
  }
  }
  //--〉
  〈/script〉

第二步:把如下代码加入〈body〉区域中

〈body background=bag.gif onload="scrollit(100)"〉

特效二:文字从状态栏的右边循环弹出

把如下代码加入〈head〉区域中

〈script language="javascript"〉
  var message = " 欢迎来到tom科技,请多提意见。谢谢! "
  var position = 150
  var delay = 10
  var scroll = new statusmessageobject()
  function statusmessageobject(p,d) {
  this.msg = message
  this.out = " "
  this.pos = position
  this.delay = delay
  this.i = 0
  this.reset = clearmessage}
  function clearmessage() {
  this.pos = position}
  function scroller() {
  for (scroll.i = 0; scroll.i < scroll.pos; scroll.i++) {
  scroll.out += " "}
  if (scroll.pos >= 0)
  scroll.out += scroll.msg
  else scroll.out = scroll.msg.substring(-scroll.pos,scroll.msg.length)
  window.status = scroll.out
  scroll.out = " "
  scroll.pos--
  if (scroll.pos < -(scroll.msg.length)) {
  scroll.reset()}
  settimeout ('scroller()',scroll.delay)}
  function snapin(jumpspaces,position) {
  var msg = scroll.msg
  var out = ""
  for (var i=0;

       

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表