为网页添加放大或缩小文字
发布时间:2006-10-14 3:09:27   收集提供:gaoqian

最近小弟看到这样的一个好东东,就是可以为我们的主页设置出一些可以放大或缩小的文字来,好东东不想独占还是拿出来吧!

代码如下:

<SCRIPT language=javascript>
<!-- Begin
var speed = 20;
var cycledelay = 1000;
var maxsize = 48;

var x = 0;
var y = 0;
var themessage, size;
var esize = "";

function initArray() {
this.length = initArray.arguments.length;
for (var i = 0; i < this.length; i++) {
this[i] = initArray.arguments[i];
}
}
var themessage2 = new initArray(
"免费软件 随意传播",
"中国电脑教育报和资源站点",
"网站:xiaoguang99122.myetang.com",
"请多多留意最新版"
);
if(navigator.appName == "Netscape")
document.write('<layer id="wds"></layer><br>');
if (navigator.appVersion.indexOf("MSIE") != -1)
document.write('<span id="wds"></span><br>');
function upwords(){
themessage = themessage2[y];
if (x < maxsize) {
x++;
setTimeout("upwords()",speed);
}
else setTimeout("downwords()",cycledelay);

if(navigator.appName == "Netscape") {
size = "<font point-size='"+x+"pt'>";
document.wds.document.write(size+"<center>"+themessage+"</center>"+esize);
document.wds.document.close();
}
if (navigator.appVersion.indexOf("MSIE") != -1){
wds.innerHTML = "<center>"+themessage+"</center>";
wds.style.fontSize=x+'px'
}
}
function downwords(){
if (x > 1) {
x--;
setTimeout("downwords()",speed);
}
else {
setTimeout("upwords()",cycledelay);
y++;
if (y > themessage2.length - 1) y = 0;
}
if(navigator.appName == "Netscape") {
size = "<font point-size='"+x+"pt'>";
document.wds.document.write(size+"<center>"+themessage+"</center>"+esize);
document.wds.document.close();
}
if (navigator.appVersion.indexOf("MSIE") != -1){
wds.innerHTML = "<center>"+themessage+"</center>";
wds.style.fontSize=x+'px'
}
}
setTimeout("upwords()",speed);
// End -->
</script>

怎么样?你的站点是不是又添加了不少光彩了。

 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50