在大学里的时候,没有什么危机感,无视自己知识的贫乏。每天仅凭着自己对知识的兴趣充实着自己。偶尔在新浪博客里写写文章,忏悔自己虚度的年华。那时候学会了使用网页特效代码,现在学了java,就试着去理解一下它们。
<script language="JavaScript">
step=0
function flash_title()
{ step++
if (step==5)
{step=1}
if (step==1) {
document.title=' ◆◇◇认识你真好◇◇◆ '}
if (step==2)
{document.title=' ◇◆◇认识你真好◇◆◇ '}
if (step==3)
{document.title=' ◇◇◆认识你真好◆◇◇ '}
if (step==4) {document.title=' ◇◆◇认识你真好◇◆◇ '}
setTimeout("flash_title()",400); }
flash_title() ;
</script>
这段代码中只涉及一点非java的内容,就是document.title=' ';这是定义本页的标题栏的,在单引号里写的东西和在<title></title>之间写东西是一样的。
所以这段代码就是:
----定义一个简单的java 函数
----设定函数每一步的执行间隔
----实例化函数(相当于在main里调用)。
<script language="JavaScript">
<!--
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
}
var POSITION = 100
var DELAY = 10
var MESSAGE = "愿你开心每一天!"
var scroll = new statusMessageObject()
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; i<position; i++)
{out += msg.charAt(i)}
for (i=1;i<jumpSpaces;i++)
{out += " "}
out += msg.charAt(position)
window.status = out
if (jumpSpaces <= 1) {
position++
if (msg.charAt(position) == ' ')
{position++ }
jumpSpaces = 100-position
} else if (jumpSpaces > 3)
{jumpSpaces *= .75}
else
{jumpSpaces--}
if (position != msg.length) {
var cmd = "snapIn(" + jumpSpaces + "," + position + ")";
scrollID = window.setTimeout(cmd,scroll.delay);
} else {
window.status=""
jumpSpaces=0
position=0
cmd = "snapIn(" + jumpSpaces + "," + position + ")";
scrollID = window.setTimeout(cmd,scroll.delay);
return false
}
return true
}
snapIn(100,0);
// -->
</script>
这里的 window.status="" 是定义状态栏的,这个例子和上一个差不多,只是看起来复杂了些。
posted on 2007-04-26 09:56
静儿 阅读(648)
评论(0) 编辑 收藏