设为首页   加入最爱           最新更新:全方位英文文章资料库
 
资料坊搜索: 标题 全文     
用JavaScript让主页上的文字飞舞
   首页>>YesizeCOM>>电脑技能坊>>Javascript>>正文       
 
广告招租,e-mail:yesize@hotmail.com

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

动态主页是每一个拥有自己主页的页面制作人员的梦想。下面我们为您介绍的文章,带来的是让您主页上的文字飞舞起来的特效方法。

现在动态主页大行其道,很多朋友都想在自己的主页里加入一些新奇的效果,我们这里说的是一个通过 javascript 实现的跟随光标的文字飞舞。浏览的效果是光标在页面不动时,光标指向右边一行不动的文字,此段文字就是会飞的,具体内容根据个人喜好了。

当光标移动的时候,第一个字开始沿光标移动的位置再次靠近光标,依次第二个字,第三个字,有一定的延时性,所以看起来就有波浪的感觉,非常的酷!而且对于页中其他元素无任何影响,当其处于编辑状态它是不显示的,就和一个空白页一样,可进行正常的编辑。区别于有些动态效果,作为 object 在编辑状态占一定空间,而在浏览状态则是动态改变的,所以会对正常编写的元素定位造成一些影响!

我将其中的所有代码列出,各位只需把飞舞的文字改成自己的就成,而对于其他代码则不要做任何修改。这些飞舞的文字在编辑状态是不出现的,怎么样?够体贴吧!好,赶紧开始吧, 全部源代码如下 :

〈html〉

〈head〉

〈title〉the fly font!〈/title〉

〈meta http-equiv=″content-type″ content=″text/html; charset=gb2312″〉

〈style〉

.spanstyle {

position:absolute;

visibility:visible;

top:-50px;

font-size:10pt;

font-family:verdana;

font-weight:bold;

color:black;

}

〈/style〉

〈script〉

/*

cursor trailor text- by only

*/

var x,y

var step=10

var flag=0

// your snappy message. important: the space at the end of the sentence!!!

var message=″ only art-about design ″

message=message.split(″ ″)

var xpos=new array()

for (i=0;i〈=message.length-1;i++) {

xpos[i]=-50

}

var ypos=new array()

for (i=0;i〈=message.length-1;i++) {

ypos[i]=-50

}

function handlermm(e){

x = (document.layers) ? e.pagex : document.body.scrollleft+event.clientx

y = (document.layers) ? e.pagey : document.body.scrolltop+event.clienty

flag=1

}

function makesnake() {

if (flag==1 && document.all) {

for (i=message.length-1; i〉=1; i--) {

xpos[i]=xpos[i-1]+step

ypos[i]=ypos[i-1]

}

xpos[0]=x+step

ypos[0]=y

for (i=0; i〈message.length-1; i++) {

var thisspan = eval(″span″+(i)+″.style″)

thisspan.posleft=xpos[i]

thisspan.postop=ypos[i]

}

}

else if (flag==1 && document.layers) {

for (i=message.length-1; i〉=1; i--) {

xpos[i]=xpos[i-1]+step

ypos[i]=ypos[i-1]

}

xpos[0]=x+step

ypos[0]=y

for (i=0; i〈message.length-1; i++) {

var thisspan = eval(″document.span″+i)

thisspan.left=xpos[i]

thisspan.top=ypos[i]

}

}

var timer=settimeout(″makesnake()″,30)

}

〈/script〉

〈script language=″javascript″〉

〈!--

function launch(newurl, newname, newfeatures, orgname) {

var remote = open(newurl, newname, newfeatures);

if (remote.opener == null)

remote.opener = window;

remote.opener.name = orgname;

return remote;

}

function launchremote() {

myremote = launch(″flash/start.html″, ″myremote″, ″height=380,width=572,channelmode=0,dependent=0,directories=0,fullscreen=0, 
location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0″,titlebar=1, ″mywindow″);

}

// --〉

〈/script〉

〈/head〉

〈body onload=″makesnake()″ style=″width:100%;overflow-x:hidden;overflow-y:scroll″ bgcolor=″#ffffff″〉

〈script language=″ ″〉

〈!-- beginning of javascript -

for (i=0;i〈=message.length-1;i++) {

document.write(″〈span id=′span″+i+″′ class=′spanstyle′〉″)

document.write(message[i])

document.write(″〈/span〉″)

}

if (document.layers){

document.captureevents(event.mousemove);

}

document.onmousemove = handlermm;

// - end of javascript - --〉

〈/script〉

〈/body〉

〈/html〉  


你只需要将这些代码拷贝下来,然后保存为*.htm 或 *.html 就可以了。注意代码的第27行 var message=″ only art - about design ″ 里面 only art - about design就是我的宣传文字,把它改成你想显示的文字就成,还支持中文呢,是不是很棒?
上一篇:JavaScript中几种去掉字串左右空格的方法 下一篇:网页制作JavaScript特效两例

版权说明:作品来源于网上,版权归作者所有,如果无意中侵犯了您的版权,请来信告知,本站将在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