网页JavaScript代码
- 格式:doc
- 大小:87.50 KB
- 文档页数:9
Javascript实现带关闭按钮的⽹页漂浮⼴告代码复制代码代码如下:<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>带关闭按钮的⽹页漂浮⼴告代码</title></head><body><div id="img" style="position: absolute; left: 311; top: 815;visibility :hidden;" onmouseover="clearInterval(interval)" onmouseout="interval = setInterval('changePos()', delay)" align="right"><a href="#" target="_blank"><img border="0" src="图⽚路径" onload="return imgzoom(this,600);"onclick="javascript:window.open(this.src);" style="cursor:pointer;"/></a><span style="CURSOR:hand;color:red;font-weight:bold" onclick="clearInterval(interval);img.style.visibility ='hidden'">X</span></div><script language=javascript src=ff.js></script></body></html>ff.js代码复制代码代码如下:var xPos = 20;var yPos = document.body.clientHeight;var step = 1;var delay = 30;var height = 0;var Hoffset = 0;var Woffset = 0;var yon = 0;var xon = 0;var pause = true;var interval;img.style.top = yPos;function changePos() {width = document.body.clientWidth;height = document.body.clientHeight;Hoffset = img.offsetHeight;Woffset = img.offsetWidth;img.style.left = xPos + document.body.scrollLeft;img.style.top = yPos + document.body.scrollTop;if (yon) {yPos = yPos + step;}else {yPos = yPos - step;}if (yPos < 0) {yon = 1;yPos = 0;}if (yPos >= (height - Hoffset)) {yon = 0;yPos = (height - Hoffset);}if (xon) {xPos = xPos + step;}else {xPos = xPos - step;}if (xPos < 0) {xon = 1;xPos = 0;}if (xPos >= (width - Woffset)) {xon = 0;xPos = (width - Woffset);}}function start() {img.style.visibility = "visible";interval = setInterval('changePos()', delay); }start();。
JavaScript实现浏览器⽹页⾃动滚动并点击的⽰例代码1. 打开浏览器控制台窗⼝JavaScript通常是作为开发Web页⾯的脚本语⾔,本⽂介绍的JavaScript代码均运⾏在指定⽹站的控制台窗⼝。
⼀般浏览器的开发者窗⼝都可以通过在当前⽹页界⾯按F12快捷键调出,然后在上⾯的标签栏找到Console点击就是控制台窗⼝,在这⾥可以直接执⾏JavaScript代码,⽽chrome系浏览器的控制台界⾯可以使⽤快捷键Ctrl+Shift+J直接打开2. 实时查看⿏标坐标⾸先为了获取当前的⿏标位置的x、y坐标,需要先重写⼀个onmousemove函数来帮助我们实时查看光标处的x、y值,⽅便下⼀步编写代码时确定初始的y坐标和每次y⽅向滚动的距离// 在控制台输⼊以下内容并回车,即可查看当前⿏标位置// 具体查看⽅式:⿏标在⽹页上滑动时⽆效果,当⿏标悬停时即可在光标旁边看到此处的坐标document.onmousemove = function(e){var x = e.pageX;var y = e.pageY;e.target.title = "X is "+x+" and Y is "+y;};3. 编写⾃动滚动代码具体代码如下,将代码粘贴进控制台并回车,然后调⽤auto_scroll()函数(具体参数含义在代码注释查看)即可运⾏// y轴是在滚动的,每次不⼀样;x坐标也每次从这些⾥⾯随机⼀个var random_x = [603, 811, 672, 894, 999, 931, 970, 1001, 1037, 1076, 1094];// 初始y坐标var position = 200;// 最⼤执⾏max_num次就多休眠⼀下var max_num = 20;// 单位是秒,每当cnt%max_num为0时就休眠指定时间(从数组中任选⼀个),单位是秒var sleep_interval = [33, 23, 47, 37, 21, 28, 30, 16, 44];// 当前正在执⾏第⼏次var cnt = 0;// 相当于random_choice的功能function choose(choices){var index = Math.floor(Math.random() * choices.length);return choices[index];};// 相当于⼴泛的random,返回浮点数function random(min_value, max_value){return min_value + Math.random() * (max_value - min_value);};// 模拟点击⿏标function click(x, y){// x = x - window.pageXOffset;// y = y - window.pageYOffset;y = y + 200;try {var ele = document.elementFromPoint(x, y);ele.click();console.log("坐标 ("+x+", "+y+") 被点击");} catch (error) {console.log("坐标 ("+x+", "+y+") 处不存在元素,⽆法点击")}};// 定时器的含参回调函数function setTimeout_func_range(time_min, time_max, step_min, step_max, short_sleep=true){if(cnt<max_num){cnt = cnt + 1;if(short_sleep){// 短休眠position = position + random(step_min, step_max);x = choose(random_x);scroll(x, position);console.log("滚动到坐标("+x+", "+position+")");click(x, position);time = random(time_min, time_max)*1000;console.log("开始" + time/1000 + 's休眠');setTimeout(setTimeout_func_range, time, time_min, time_max, step_min, step_max);// console.log(time/1000 + 's休眠已经结束');}else{// 长休眠,且不滑动,的回调函数time = random(time_min, time_max)*1000;console.log("开始" + time/1000 + 's休眠');setTimeout(setTimeout_func_range, time, time_min, time_max, step_min, step_max);// console.log(time/1000 + 's休眠已经结束');}}else{cnt = 0;console.log("⼀轮共计"+max_num+"次点击结束");time = choose(sleep_interval)*1000;console.log("开始" + time/1000 + 's休眠');setTimeout(setTimeout_func_range, time, time_min, time_max, step_min, step_max, false);// console.log(time/1000 + 's休眠已经结束(长休眠且不滑动)');}};// ⾃动滚动⽹页的启动函数// auto_scroll(5, 10, 50, 200)表⽰每隔5~10秒滚动⼀次;每次滚动的距离为50~200⾼度function auto_scroll(time_min, time_max, step_min, step_max){time = random(time_min, time_max)*1000;console.log("开始" + time/1000 + 's休眠');setTimeout(setTimeout_func_range, time, time_min, time_max, step_min, step_max);// console.log(time/1000 + 's休眠已经结束');};/*---------以下内容⽆需⽤到,根据情况使⽤----------// ⾃定义click的回调函数// 若绑定到元素,则点击该元素会出现此效果function click_func(e){var a = new Array("富强","民主","⽂明","和谐","⾃由","平等","公正","法治","爱国","敬业","诚信","友善"); var $i = $("<span></span>").text(a[a_idx]);a_idx = (a_idx + 1) % a.length;var x = e.pageX,y = e.pageY;$i.css({"z-index": 999999999999999999999999999999999999999999999999999999999999999999999,"top": y - 20,"left": x,"position": "absolute","font-weight": "bold","color": "rgb("+~~(255*Math.random())+","+~~(255*Math.random())+","+~~(255*Math.random())+")" });$("body").append($i);$i.animate({"top": y - 180,"opacity": 0},1500,function() {$i.remove();});};// 在控制台输⼊以下内容,即可查看当前⿏标位置document.onmousemove = function(e){var x = e.pageX;var y = e.pageY;e.target.title = "X is "+x+" and Y is "+y;};*/代码运⾏效果如下以上就是JavaScript实现浏览器⽹页的⾃动滚动并点击的⽰例代码的详细内容,更多关于JavaScript 浏览器⾃动滚动点击的资料请关注其它相关⽂章!。
JavaScript脚本语言在网页交互中的使用教程随着互联网的不断发展,网页已经成为人们获取信息、进行交流和娱乐的重要场所。
而JavaScript作为一种脚本语言,具备强大的网页交互能力和灵活性,在网页开发中扮演着重要的角色。
本篇文章将为您介绍JavaScript脚本语言在网页交互中的使用教程。
一、引入JavaScript在学习JavaScript之前,首先要学会如何在网页中引入JavaScript脚本。
一般而言,可以通过script标签将JavaScript代码嵌入到HTML文档中。
具体的引入方式如下所示:```html<script>// 在这里编写JavaScript代码</script>```另外,也可以通过外部引入的方式,将JavaScript代码放置在一个独立的.js文件中,再通过script标签引入,如下所示:```html<script src="script.js"></script>```在HTML中,我们可以放置多个script标签,这样可以将JavaScript分成多个模块,使代码结构更加清晰。
二、基本语法和数据类型学习任何一门编程语言,都必须先了解它的基本语法和数据类型。
JavaScript的基本语法和大部分语言非常相似,包括变量声明、条件语句、循环语句等。
以下是一些常用的语法示例:```javascript// 变量声明var message = "Hello World!";// 条件语句if (condition) {// 如果条件成立,执行这里的代码} else {// 如果条件不成立,执行这里的代码}// 循环语句for (var i = 0; i < 10; i++) {// 执行循环体代码}// 函数声明function sayHello(name) {console.log("Hello, " + name + "!");}```JavaScript支持多种数据类型,包括字符串、数字、布尔值、数组和对象等。
网页显示月份、日期、星期、时间代码一、网页显示月份、日期、星期代码<script language=JavaScript>today=new Date();function initArray(){this.length=initArray.arguments.lengthfor(var i=0;i<this.length;i++)this[i+1]=initArray.arguments[i] }var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六");document.write("<font color=##000000 style='font-size:9pt;font-family: 宋体'> ",today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日",d[today.getDay()+1],"</font>" );</script>二、六种风格时间显示,一定有你喜欢的!<SCRIPT language="javascript"><!--function initArray(){for(i=0;i<initArray.arguments.length;i++)this[i]=initArray.arguments[i];}var isnMonths=new initArray("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");var isnDays=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六","星期日");today=new Date();hrs=today.getHours();min=today.getMinutes();sec=today.getSeconds();clckh=""+((hrs>12)?hrs-12:hrs);clckm=((min<10)?"0":"")+min;clcks=((sec<10)?"0":"")+sec;clck=(hrs>=12)?"下午":"上午";var stnr="";var ns="0123456789";var a="";function getFullYear(d){yr=d.getYear();if(yr<1000)yr+=1900;return yr;}document.write("<table>");//下面各行分别是一种风格,把不需要的删掉即可document.write("<TR><TD>风格一:</TD><TD>"+isnDays[today.getDay()]+","+isnMonths[today. getMonth()]+""+today.getDate()+"日,"+getFullYear(today)+"年");document.write("<TR><TD>风格二:</TD><TD>"+clckh+":"+clckm+":"+clcks+""+clck+"</TD></TR>");document.write("<TR><TD>风格三:</TD><TD>"+isnDays[today.getDay()]+","+isnMonths[today. getMonth()]+""+today.getDate()+"日,"+getFullYear(today)+"年"+clckh+":"+clckm+":"+clcks+""+clck+"</TD></TR>");document.write("<TR><TD>风格四:</TD><TD>"+(today.getMonth()+1)+"/"+today.getDate()+"/ "+(getFullYear(today)+"").substring(2,4)+"</TD></TR>");document.write("<TR><TD>风格五:</TD><TD>"+hrs+":"+clckm+":"+clcks+"</TD></TR>");document.write("<TR><TD VALIGN=TOP>风格六:</TD><TD>"+today+"</TD></TR>");document.write("</table>");//--></SCRIPT>三、这个时钟是有影子的,而且还在不停地走着呢<div id="bgclockshade" style="position:absolute;visibility:visible;font-family:'Arialblack';color:#cccccc;font-size:20px;top:50px;left:173px"></div> <div id="bgclocknoshade" style="position:absolute;visibility:visible;font-family:'Arialblack';color:#000000;font-size:20px;top:48px;left:170px"></div> <div id="mainbody" style="position:absolute; visibility:visible"></div><script language=javaScript><!--function www_helpor_net() {thistime= new Date()var hours=thistime.getHours()var minutes=thistime.getMinutes()var seconds=thistime.getSeconds()if (eval(hours) <10) {hours="0"+hours}if (eval(minutes) < 10) {minutes="0"+minutes}if (seconds < 10) {seconds="0"+seconds}thistime = hours+":"+minutes+":"+secondsif(document.all) {bgclocknoshade.innerHTML=thistimebgclockshade.innerHTML=thistime}if(yers) {document.bgclockshade.document.write('<divid="bgclockshade"style="position:absolute;visibility:visible;font-family:Verdana;color:FFAAAAA;font-size:20px;top:10px;left:152px">'+thistime+'</div>')document.bgclocknoshade.document.write('<divid="bgclocknoshade"style="position:absolute;visibility:visible;font-family:Verdana;color:DDDDDD;font-size:20px;top:8px;left:150px">'+thistime+'</div>')document.close()}var timer=setTimeout("www_helpor_net()",200)}www_helpor_net();//--></script>四、数字化的时钟<span id="liveclock" style"=width: 109px; height:15px"></span><SCRIPT language=javascript>function www_helpor_net(){var Digital=new Date()var hours=Digital.getHours()var minutes=Digital.getMinutes()var seconds=Digital.getSeconds()if(minutes<=9)minutes="0"+minutesif(seconds<=9)seconds="0"+secondsmyclock="现在时刻:<font size='5' face='Arial black'>"+hours+":"+minutes+":"+seconds+"</font>"if(yers){yers.liveclock.document.wri te(myclock)yers.liveclock.document.close()}else if(document.all)liveclock.innerHTML=myclocksetTimeout("www_helpor_net()",1000)}www_helpor_net();//--></SCRIPT>五、动态时钟代码2,此代码相当简单<SCRIPT>setInterval("jnkc.innerHTML=newDate().toLocaleString()+' 星期'+'日一二三四五六'.charAt (new Date().getDay());",1000);</SCRIPT>六、flash时钟,改变sz1.swf中的1为0、1、2、3、4、5、6,可以获得不同样式的时钟,你试试吧。
javascript最简单爱心代码JavaScript是一种广泛应用于网页开发的编程语言,它的灵活性和简便性使得许多人喜欢使用它来实现各种有趣的效果。
其中,通过JavaScript代码实现一个简单的爱心效果是一项非常受欢迎的任务。
在本文中,我们将介绍如何使用JavaScript编写最简单的爱心代码,并解释其原理。
让我们来看一下这个爱心效果的代码:```javascriptconsole.log('♥');```这段代码非常简单,只有一行,但它却能在控制台输出一个可爱的爱心符号。
接下来,我们将逐步解释这段代码的含义。
`console`是JavaScript提供的一个对象,它可以用来在浏览器的控制台上输出信息。
`log`是`console`对象的一个方法,用于输出一条信息。
在这段代码中,我们传递给`log`方法的参数是一个字符串`'♥'`。
这个字符串中的`♥`是一个特殊的字符,它代表了一个爱心符号。
当代码执行时,控制台会输出这个爱心符号,从而实现了爱心效果。
这个爱心符号是如何实现的呢?其实,这是由Unicode字符集中的一个特殊字符所实现的。
Unicode是一种用于表示文字字符的标准,它为每个字符分配了一个唯一的编号。
在Unicode字符集中,爱心符号的编号是U+2665。
在JavaScript中,我们可以使用`\u`前缀加上这个编号来表示这个字符。
因此,`'♥'`就是代表了这个爱心符号。
除了使用控制台输出爱心符号,我们还可以将它显示在网页上。
下面是一个简单的HTML代码,用于在网页上显示这个爱心符号:```html<!DOCTYPE html><html><head><title>最简单爱心代码</title></head><body><div id="heart"></div><script>var heartElement = document.getElementById('heart');heartElement.innerHTML = '♥';</script></body></html>```在这段代码中,我们首先创建了一个`<div>`元素,并给它指定了一个id属性为`heart`。
对于<a href="javascript:jump(“”)>的详细讲解一. Js代码在页面跳转的几种方式第1种:<script language="javascript" type="text/javascript">window.location.href="login.jsp?backurl="+window.location.href; </script>第2种:<script language="javascript">alert("返回");window.history.back(-1);</script>第3种:<script language="javascript">window.navigate("top.jsp");</script>第4种:<script language="JavaScript">self.location='top.htm';</script>第5种:<script language="javascript">alert("非法访问!");top.location='xx.jsp';</script>二.javascript:指的是伪协议,是指用url的形式调用javascript这句话相当于调用了javascript方法jump(“”);三.另外摘自网友的描述:关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法"window.location.href"、"location.href"是本页面跳转"parent.location.href"是上一层页面跳转"top.location.href"是最外层的页面跳转举例说明:如果A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js这样写"window.location.href"、"location.href":D页面跳转"parent.location.href":C页面跳转"top.location.href":A页面跳转如果D页面中有form的话,<form>: form提交后D页面跳转<form target="_blank">: form提交后弹出新页面<form target="_parent">: form提交后C页面跳转<form target="_top"> : form提交后A页面跳转关于页面刷新,D 页面中这样写:"parent.location.reload();": C页面刷新(当然,也可以使用子窗口的opener 对象来获得父窗口的对象:window.opener.document.location.reload(); )"top.location.reload();": A页面刷新。
如何使用JavaScript创建动态网页交互效果一、引言动态网页交互效果是现代网页设计的重要组成部分,JavaScript 作为一种通用的脚本语言,具有在网页上实现动态效果的能力。
本文将介绍如何使用JavaScript创建动态网页交互效果的方法和技巧。
二、基础知识1.理解JavaScript:JavaScript是一种解释型脚本语言,可以在客户端的网页上运行。
它能够通过操作DOM(文档对象模型)和CSS(层叠样式表)来实现网页的动态效果。
2.DOM操作:DOM是指网页的文档对象模型,它可以用来访问和操作网页的元素。
通过JavaScript的DOM方法,我们可以修改网页的内容、样式和结构。
3.CSS操作:CSS是一种用来控制网页样式的技术。
通过JavaScript,我们可以动态地改变网页元素的CSS属性,如颜色、大小和位置等。
三、常见动态网页交互效果及实现方法1.响应用户交互:- 实时搜索提示:通过监听用户在搜索框输入的内容,使用AJAX技术向服务器请求数据并实时显示相关搜索建议。
- 鼠标悬停效果:通过监听用户鼠标的移动,改变元素的样式,如颜色、透明度或背景等,来实现动态效果。
2.动画效果:- 轮播图:使用JavaScript控制元素的显示和隐藏,通过设置定时器和切换元素的位置,实现轮播效果。
- 渐变过渡:通过改变元素的透明度或位置属性,结合CSS的transition属性,使元素的改变平滑地过渡。
3.表单验证:- 实时验证:通过监听用户在表单输入的内容,使用正则表达式或其他验证方法,实时判断输入是否合法,并给出相应的提示信息。
- 提交验证:在表单提交之前,使用JavaScript对用户输入的内容进行验证,判断是否符合要求,并给出相应的提示信息。
四、实现技巧和方法1.事件监听:通过addEventListener方法,可以监听用户的各种交互事件,如点击、鼠标移动、滚动等。
在事件发生时,可以执行相应的JavaScript代码来实现动态效果。
网页javascript脚本运行操作方法要运行Web页上的JavaScript脚本,可以通过以下几种方法:1. 内联方式:直接在HTML文件中使用<script>标签内嵌JavaScript代码。
例如:html<!DOCTYPE html><html><head><title>My Website</title></head><body><h1>Hello World!</h1><script>console.log("This is a JavaScript code.");</script></body></html>2. 外部引用方式:在HTML文件中使用<script>标签引用外部的JavaScript 文件。
例如:html<!DOCTYPE html><html><head><title>My Website</title><script src="script.js"></script></head><body><h1>Hello World!</h1></body></html>在这个例子中,script.js是一个独立的JavaScript文件,包含要运行的脚本代码。
3. 事件绑定方式:在HTML元素上绑定事件,当事件触发时执行JavaScript代码。
例如:html<!DOCTYPE html><html><head><title>My Website</title><script>function myFunction() {console.log("Button clicked");}</script></head><body><h1>Hello World!</h1><button onclick="myFunction()">Click me</button></body></html>在这个例子中,当用户点击按钮时,会调用myFunction函数,并在控制台打印一条消息。
javasc ript常用代码大全-网页设计,HTM LCSS//打开模式对话框fun ction dose lectu ser(t xtid){ s trfea tures="dia logwi dth=500px;dialo gheig ht=360px;c enter=yes;middl e=yes ;hel p=n o;statu s=no;scrol l=no";v ar ur l,str retur n; ur l="se luser.aspx";s trret urn=w indow.show modal dialo g(url,,str featu res);}//返回模式对话框的值funct ion o kbtn_oncli ck(){v ar co mmstr=; windo w.ret urnva lue=c ommst r; wi ndow.close() ;}全屏幕打开ie 窗口var winw idth=scree n.ava ilwid th ;varwinhe ight=scree n.ava ilhei ght-20;w indow.open("mai n.asp x","s urvey windo w","t oolba r=no,width="+ w inwid th +",hei ght=" + win heigh t +",top=0,lef t=0,s croll bars=yes,r esiza ble=y es,ce nter:yes,s tatus bars=yes"); br eak //脚本中中使用xm lfu nctio n ini tiali ze(){var x mldocv ar xs ldoc xmld oc =new a ctive xobje ct(mi croso ft.xm ldom)x mldoc.asyn c = f alse;xsl doc = newactiv exobj ect(m icros oft.x mldom)xsldo c.asy nc =false;xml doc.l oad("tree.xml")x sldoc.load("tre e.xsl")fol dertr ee.in nerht ml =xmldo c.doc ument eleme nt.tr ansfo rmnod e(xsl doc)}一、验证类1、数字验证内1.1 整数1.2 大于0的整数(用于传来的id的验证) 1.3负整数的验证 1.4整数不能大于imax1.5 整数不能小于i min 2、时间类2.1 短时间,形如(13:04:06)2.2 短日期,形如(2003-12-05) 2.3长时间,形如 (2003-12-05 13:04:06) 2.4只有年和月。
按钮<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""/TR/xhtml1/DTD/xhtml1-str ict.dtd"><title>3D按钮</title><style type="text/css"><!--a{display:block;width:50px;height:15px;border:2px outset #ccc;background:#ccc;text-align:center;font-size:12px;color:#fff;text-decoration:none;padding-top:2px;}a:hover {border:2px inset #ccc;background:#ccc;text-decoration:none;}--></style><a href="">搜索</a>打字<html><head><title>脚本代码|中国站长站|---打印文字特效</title></head><body bgcolor="#000000" OnLoad="textticker()"><!-- 用<body bgcolor="#fef4d9" OnLoad="textticker()">替换原有的<body> --> <!--将以下代码加入HTML的<Body></Body>之间--><SCRIPT LANGUAGE="JavaScript"><!-- Beginvar max=0;function textlist() { max=textlist.arguments.length;for (i=0; i<max; i++)this[i]=textlist.arguments[i];}tl = new textlist('中国站长站--为中文站长提供动力!');var x = 0; pos = 0;var l = tl[0].length;function textticker() {document.tickform.tickfield.value = tl[x].substring(0, pos) + "_";if(pos++ == l) {pos = 0;setTimeout("textticker()", 400);if(++x == max) x = 0;l = tl[x].length;} elsesetTimeout("textticker()", 200);}// End --></script><form name=tickform><textarea name=tickfield rows=3 cols=38 style="background-color: rgb(0,0,0); color: rgb(255,255,255); cursor: default; font-family: Arial; font-size: 12px" wrap=virtual>cool滚动<head><title>中国站长站---滚动文字淡入淡出效果</title><meta content="text/html; charset=gb2312" http-equiv="Content-Type"><style type="text/css">.textanimlink { TEXT-DECORATION: none}A {TEXT-DECORATION: none}P.main {FONT-FAMILY: Arial; FONT-SIZE: 15pt; FONT-WEIGHT: bold}</style><meta http-equiv="Page-Enter" content="revealTrans(Duration=1.0,Transitio n=0)"></head><body bgproperties="fixed"><script language="Javascript">bname=navigator.appName;bversion=parseInt(navigator.appVersion)if ((bname=="Netscape" && bversion>=4) || (bname=="Microsoft Internet Explorer" && bversion>=4))window.onload=startelsestop();window.onunload=stopif (bname=="Netscape"){brows=truedt=2}else{brows=falsedt=20}var z=0;var msg=0;var rgb=0;var link=false;var status=true;var updwn=false;var message= new Array();var value=0;var h=window.innerHeight;var w=window.innerWidth;var timer1;var timer2;var timer3;var convert = new Array()var hexbase= new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"); var bgcolor="#0000FF"; //背景色var color="#FF0000"; //字符颜色message[0]='<a href="">★中国站长站★</a>'message[1]='<a href="">★中国站长站素材★</a>'message[2]='<ahref="">★中国站长站脚本★</a>'message[3]='<a href="">★欢迎光临中国站长站★</a>'for (x=0; x<16; x++){for (y=0; y<16; y++){convert[value]= hexbase[x] + hexbase[y]; value++;}}redx=color.substring(1,3);greenx=color.substring(3,5);bluex=color.substring(5,7);hred=eval(parseInt(redx,16));hgreen=eval(parseInt(greenx,16));hblue=eval(parseInt(bluex,16));eredx=bgcolor.substring(1,3);egreenx=bgcolor.substring(3,5);ebluex=bgcolor.substring(5,7);ered=eval(parseInt(eredx,16));egreen=eval(parseInt(egreenx,16));eblue=eval(parseInt(ebluex,16));red=ered;green=egreen;blue=eblue;function start(){if ((bname=="Netscape" && bversion>=4) || (bname=="Microsoft Internet Explorer" && bversion>=4)){link=false;updwn=true;if (brows)res=yers['textanim'].topelse{textanim.style.width=document.body.offsetWi dth-20;textanim.innerHTML='<Pre><P Class="main" Align="Center">'+message[msg]+'</P></Pre>' res=textanim.style.topfor (x=0; x<document.all.length; x++)if(document.all[x].id=="textanimlink")link=true;}up()}}function stop(){clearTimeout(timer1);clearTimeout(timer2);clearTimeout(timer3);}function resz(){h=window.innerHeight;w=window.innerWidth;if (updwn)timer1=setTimeout('up()',1000)elsetimer2=setTimeout('down()',1000)}function breakf(){if (status){clearTimeout(timer1);clearTimeout(timer2);status=falsereturn;}else{status=true;if (updwn)timer1=setTimeout('up()',dt)elsetimer2=setTimeout('down()',dt)} }function up(){if (red<hred){if ((red+7)<hred)red+=7;elsered=hredredx = convert[red]}else{if ((red-7)>hred)red-=7;elsered=hredredx = convert[red]}if (green<hgreen){if ((green+7)<hgreen) green+=7;elsegreen=hgreengreenx = convert[green] }else{if ((green-7)>hgreen) green-=7;elsegreen=hgreengreenx = convert[green] }if (blue<hblue){if ((blue+7)<hblue) blue+=7;elseblue=hbluebluex = convert[blue] }else{if ((blue-7)>hblue) blue-=7;blue=hbluebluex = convert[blue]}rgb = "#"+redx+greenx+bluex;if (brows){yers['textanim'].document.linkCo lor=rgb;yers['textanim'].document.vlinkC olor=rgb;if (window.innerHeight!=h || window.innerWidth!=w){clearTimeout(timer1);resz()return;}else{yers['textanim'].document.write( '<Pre><P Class="main" Align="Center"><font color="'+rgb+'">'+message[msg]+'</font></P> </Pre>')yers['textanim'].document.close( );}}else{textanim.style.color=rgb;if(link)textanimlink.style.color=rgb;}if (z<38){if (brows)yers['textanim'].top--elsetextanim.style.posTop--z++timer1=setTimeout('up()',dt)}else{updwn=false;down()} function down(){if (red<ered){if ((red+7)<ered)red+=7;elsered=eredredx = convert[red]}else{if ((red-7)>ered)red-=7;elsered=eredredx = convert[red]}if (green<egreen){if ((green+7)<egreen) green+=7;elsegreen=egreengreenx = convert[green] }else{if ((green-7)>egreen) green-=7;elsegreen=egreengreenx = convert[green] }if (blue<eblue){if ((blue+7)<eblue) blue+=7;elseblue=ebluebluex = convert[blue] }else{if ((blue-7)>eblue) blue-=7;blue=ebluebluex = convert[blue]}rgb = "#"+redx+greenx+bluex;if (brows){yers['textanim'].document.linkCo lor=rgb;yers['textanim'].document.vlinkC olor=rgb;if (window.innerHeight!=h || window.innerWidth!=w){clearTimeout(timer2);resz()return;}else{yers['textanim'].document.write( '<Pre><P Class="main" Align="Center"><font color="'+rgb+'">'+message[msg]+'</font></P> </Pre>')yers['textanim'].document.close( );}}else{textanim.style.color=rgb;if(link)textanimlink.style.color=rgb;}if (z<76){if (brows)yers['textanim'].top--elsetextanim.style.posTop--z++timer2=setTimeout('down()',dt)}else{if (brows){yers['textanim'].document.write(yers['textanim'].document.close( );}elsetextanim.innerHTML='';window.clearInterval(timer2);if(msg<message.length-1){msg++;z=0;if (brows){yers['textanim'].top=res;}elsetextanim.style.top=res;timer3=setTimeout('start()',100);}else{msg=0;z=0;if (brows)yers['textanim'].top=res;elsetextanim.style.top=res;timer3=setTimeout('start()',2000);}}}</script><div id="textanim" onclick="breakf()"style="left: 36; position: absolute; top: 60; width: 447; height: 19"> </div></body>水性文字<HTML><HEAD><TITLE>Cool-中国站长站</TITLE><STYLE>DIV {width: 609; font-size: 40pt; font-family: Tahoma;font-weight: bold;}</STYLE><SCRIPT LANGUAGE="JavaScript">var count=0; var thePhase=0; var aniOn=0;var theStrength=0;var maxCount=40;var maxStrength=100;var theCount=0;var colorList=new Array("red", "blue", "green");var oDiv=null;var oQueue=new Array();function doStart(obj){oDiv=obj;oQueue.push("Welcome to 51js!");oQueue.push("Hello Friends!");oQueue.push("I love you");if(obj==null)return;if(!oQueue.length)return;oDiv.innerHTML=oQueue.shift();varctrlRng=document.body.createControlRange() ctrlRng.add(oDiv)ctrlRng.select();ctrlRng.execCommand("SelectAll")theCount=0;doFilt();}function getStrength(pos){var ret=0if(pos<maxCount){ret=maxStrength*pos*pos/(maxCount*maxCo unt);}else if(pos==maxCount){strNext=oQueue.shift()oDiv.innerHTML=strNext;rndNum=Math.floor(Math.random() * 3)oDiv.style.filter+="glow(color=" + colorList[rndNum] + ", strength=5)"ret=maxStrength;}else if(pos<2*maxCount){pos=2*maxCount-pos;ret=maxStrength*pos*pos/(maxCount*maxCo unt);}elseret=0;ret=Math.ceil(ret)return ret;}function anitext(){thePhase=(thePhase + 10)oDiv.filters[0].phase=thePhasetheStrength=getStrength(++theCount);window.status=theStrengthif(theStrength==0)theCount=0;if(oQueue.length>0 || theStrength>0){oDiv.filters[0].strength=theStrength;oTO=window.setTimeout("anitext()",0200,"Jav aScript")}}function doFilt(){oDiv.style.filter="wave(add=0, freq=3, lightstrength=50, phase=0, strength=2, enabled=1); "rndNum=Math.floor(Math.random() * 3)oDiv.style.filter+="glow(color=" + colorList[rndNum] + ", strength=5)"anitext()}function removeFilt(){window.clearTimeout(oTO)oDiv.style.filter=" "}function arrPush(item){this[this.length]=item;}function arrShift(){var item=this[0];var nLen=this.length;for(var i=0;i<nLen-1;i++)this[i]=this[i+1];this.length--;return item;}Array.prototype.push=arrPush;Array.prototype.shift=arrShift;</SCRIPT></HEAD><BODY onload="doStart(MyDiv)"><DIV ID="MyDiv" align="center"></DIV></BODY></HTML>1.让文字不停地滚动<MARQUEE>滚动文字</MARQUEE>2.记录并显示网页的最后修改时间<script language=Javascript>document.write("最后更新时间: " + stModified + "")</script>3.关闭当前窗口< a href="/"onClick="javascript:window.close(); return false;">关闭窗口</a>4.5秒后关闭当前页<script language="Javascript"><!--setTimeout('window.close();',5000);--></script>5.2秒后载入指定网页<head><meta http-equiv="refresh" content="2;URL=http://你的网址"></head>6.添加到收藏夹<script Language="Javascript">function bookmarkit(){window.external.addFavorite('http://你的网址','你的网站名称')}if (document.all)document.write('<a href="#" onClick="bookmarkit()">加入收藏夹</a>')</script>7.让超链接不显示下划线<style type="text/css"><!-a:link{text-decoration:none}a:hover{text-decoration:none}a:visited{text-decoration:none}-></style>8.禁止鼠标右键的动作<script Language = "Javascript">function click() { if (event.button==2||event.button==3){alert('禁止鼠标右键');}document.onmousedown=click // --></script>9.设置该页为首页<body bgcolor="#FFFFFF" text="#000000"><!-- 网址:http://你的网址--><a class="chlnk" style="cursor:hand" HREFonClick="this.style.behavior='url(#default# homepage)';this.setHomePage('你的网站名称);"><font color="000000" size="2" face="宋体">设为首页</font></a></body>10.节日倒计时<script Language="Javascript">var timedate= new Date("December 25,2003");var times="圣诞节";var now = new Date();var date = timedate.getTime() - now.getTime();var time = Math.floor(date / (1000 * 60 * 60 * 24));if (time >= 0)document.write("现在离"+times+"还有: "+time +"天")</script>11.单击按钮打印出当前页<script Language="Javascript"><!-- Beginif (window.print) {document.write('<form>'+ '<input type=button name=print value="打印本页" '+ 'onClick="javascript:window.print()"></form>');}// End --></script>12.单击按钮‘另存为’当前页<input type="button" name="Button" value="保存本页"onClick="document.all.button.ExecWB(4,1)"><object id="button"width=0height=0classid="CLSID:8856F961-340A-11D0-A96B-00C0 4FD705A2"><embed width="0" height="0"></embed></object>13.显示系统当前日期<script language=Javascript>today=new Date();function date(){this.length=date.arguments.lengthfor(var i=0;i<this.length;i++)this[i+1]=date.arguments }var d=new date("星期日","星期一","星期二","星期三","星期四","星期五","星期六");document.write("<font color=##000000 style='font-size:9pt;font-family: 宋体'> ",today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日",d[today.getDay()+1],"</font>" );</script>14.不同时间段显示不同问候语<script Language="Javascript"><!--var text=""; day = new Date( ); time = day.getHours( );if (( time>=0) && (time < 7 ))text="夜猫子,要注意身体哦! "if (( time >= 7 ) && (time < 12))text="今天天气……哈哈哈,不去玩吗?"if (( time >= 12) && (time < 14))text="午休时间哦,朋友一定是不习惯午睡的吧?!"if (( time >=14) && (time < 18))text="下午茶的时间到了,休息一下吧!"if ((time >= 18) && (time <= 22))text="您又来了,可别和MM聊太久哦!"if ((time >= 22) && (time < 24))text="很晚了哦,注意休息呀!"document.write(text)//---></script>15.水中倒影效果<img id="reflect" src="你自己的图片文件名" width="175" height="59"><script language="Javascript">function f1(){setInterval("mdiv.filters.wave.phase+=10",1 00);}if (document.all){document.write('<img id=mdiv src="'+document.all.reflect.src+'"style="filter:wave(strength=3,freq=3,phase=0,lightstrength=30) blur() flipv()">')window.onload=f1}</script>16.慢慢变大的窗口<script Language="Javascript"><!--var Windowsheight=100var Windowswidth=100var numx=5function openwindow(thelocation){temploc=thelocationif(!(window.resizeTo&&document.all)&&!(window.resizeTo&&document.getElementById)){window.open(thelocation)return}windowsize=window.open("","","scrollbars") windowsize.moveTo(0,0)windowsize.resizeTo(100,100)tenumxt()}function tenumxt(){if (Windowsheight>=screen.availHeight-3) numx=0windowsize.resizeBy(5,numx)Windowsheight+=5Windowswidth+=5if (Windowswidth>=screen.width-5){windowsize.location=templocWindowsheight=100Windowswidth=100numx=5return}setTimeout("tenumxt()",50)}//--></script><p>< a href="javascript:openwindow(http://www.3yde )">进入</a>17.改变IE地址栏的IE图标我们要先做一个16*16的icon(图标文件),保存为index.ico。