炫酷的网页特效代码,html5酷炫代码

http://www.itjxue.com  2023-01-14 03:52  来源:未知  点击次数: 

网页特效代码

打字效果的文字特效[修改显示的文字即可]

[根据下面的说明进行共1步]

====2、以下代码放在HTML的body/body之间[适当的位置]:

script language=javascript

var layers =document.layers,style=document.all,both=layers||style,idme=908601;

if(layers){layerRef='document.layers';styleRef ='';}if(style){layerRef='document.all';styleRef =

'.style';}

function writeOnText(obj,str){

if(layers)with(document[obj]){ document.open();document.write(str);document.close();}

if(style)eval(obj+'.innerHTML=str'); }

var dispStr=new Array("javascript源码大全");

var overMe=0;

function txtTyper(str,idx,idObj,spObj,clr1,clr2,delay,plysnd){

var tmp0=tmp1= '',skip=100;

if (both idx=str.length) {

if (str.charAt(idx)==''){ while(str.charAt(idx)!='') idx++;idx++;}

if (str.charAt(idx)==''str.charAt(idx+1)!=' '){ while (str.charAt(idx)!= ';')idx++;idx++;}

tmp0 = str.slice(0,idx);

tmp1 = str.charAt(idx++);

if (overMe==0 plysnd==1){

if (navigator.plugins[0]){

if(navigator.plugins["LiveAudio"][0].type=="audio/basic" navigator.javaEnabled()){document.embeds

[0].stop();

setTimeout("document.embeds[0].play(false)",100);}

} else if (document.all){

ding.Stop();

setTimeout("ding.Run()",100);}

overMe=1;}else overMe=0;

writeOnText(idObj, "span class="+spObj+"font color='"+clr1+"'"+tmp0+"/fontfont color='"+clr2

+"'"+tmp1+"/font/span");

setTimeout("txtTyper('"+str+"', "+idx+", '"+idObj+"', '"+spObj+"', '"+clr1+"', '"+clr2+"', "+delay+" ,"+plysnd+")",delay);}}

function init(){txtTyper(dispStr[0], 0, 'ttl0', 'ttl1', '#339933', '#99FF33', 300, 0);}

/script

BODY onload=init()

DIV class=ttl1 id=ttl0/DIV

/BODY

急求各种网页鼠标特效代码(只要代码,不要网址)

很酷的跟随鼠标的三色彩带

html

head

title网页特效|Linkweb.cn/Js|---很酷的跟随鼠标的三色彩带/title

/headbody bgColor=#000000

!--将以下代码加入HTML的Body/Body之间--

script language="JavaScript"

!--

var a_Colour='fff000';

var b_Colour='00ff00';

var c_Colour='ff00ff';

var Size=120;

var YDummy=new Array(),XDummy=new Array(),xpos=0,ypos=0,ThisStep=0;step=0.6;

if (document.layers){

window.captureEvents(Event.MOUSEMOVE);

function nsMouse(evnt){

xpos = window.pageYOffset+evnt.pageX+6;

ypos = window.pageYOffset+evnt.pageY+16;

}

window.onMouseMove = nsMouse;

}

else if (document.all)

{

function ieMouse(){

xpos = document.body.scrollLeft+event.x+6;

ypos = document.body.scrollTop+event.y+16;

}

document.onmousemove = ieMouse;

}

function swirl(){

for (i = 0; i 3; i++)

{

YDummy[i]=ypos+Size*Math.sin((1*Math.sin((ThisStep)/10))+i*2)*Math.sin((ThisStep)/4);

XDummy[i]=xpos+Size*Math.cos((1*Math.sin((ThisStep)/10))+i*2)*Math.sin((ThisStep)/4);

}

ThisStep+=step;

setTimeout('swirl()',10);

}

var amount=10;

if (document.layers){

for (i = 0; i amount; i++)

{

document.write('layer name=nsa'+i+' top=0 left=0 width='+i/2+' height='+i/2+' bgcolor='+a_Colour+'/layer');

document.write('layer name=nsb'+i+' top=0 left=0 width='+i/2+' height='+i/2+' bgcolor='+b_Colour+'/layer');

document.write('layer name=nsc'+i+' top=0 left=0 width='+i/2+' height='+i/2+' bgcolor='+c_Colour+'/layer');

}

}

else if (document.all){

document.write('div id="ODiv" style="position:absolute;top:0px;left:0px"'

+'div id="IDiv" style="position:relative"');

for (i = 0; i amount; i++)

{

document.write('div id=x style="position:absolute;top:0px;left:0px;width:'+i/2+';height:'+i/2+';background:'+a_Colour+';font-size:'+i/2+'"/div');

document.write('div id=y style="position:absolute;top:0px;left:0px;width:'+i/2+';height:'+i/2+';background:'+b_Colour+';font-size:'+i/2+'"/div');

document.write('div id=z style="position:absolute;top:0px;left:0px;width:'+i/2+';height:'+i/2+';background:'+c_Colour+';font-size:'+i/2+'"/div');

}

document.write('/div/div');

}

function prepos(){

var ntscp=document.layers;

var msie=document.all;

if (document.layers){

for (i = 0; i amount; i++)

{

if (i amount-1)

{

ntscp['nsa'+i].top=ntscp['nsa'+(i+1)].top;ntscp['nsa'+i].left=ntscp['nsa'+(i+1)].left;

ntscp['nsb'+i].top=ntscp['nsb'+(i+1)].top;ntscp['nsb'+i].left=ntscp['nsb'+(i+1)].left;

ntscp['nsc'+i].top=ntscp['nsc'+(i+1)].top;ntscp['nsc'+i].left=ntscp['nsc'+(i+1)].left;

}

else

{

ntscp['nsa'+i].top=YDummy[0];ntscp['nsa'+i].left=XDummy[0];

ntscp['nsb'+i].top=YDummy[1];ntscp['nsb'+i].left=XDummy[1];

ntscp['nsc'+i].top=YDummy[2];ntscp['nsc'+i].left=XDummy[2];

}

}

}

else if (document.all){

for (i = 0; i amount; i++)

{

if (i amount-1)

{

msie.x[i].style.top=msie.x[i+1].style.top;msie.x[i].style.left=msie.x[i+1].style.left;

msie.y[i].style.top=msie.y[i+1].style.top;msie.y[i].style.left=msie.y[i+1].style.left;

msie.z[i].style.top=msie.z[i+1].style.top;msie.z[i].style.left=msie.z[i+1].style.left;

}

else

{

msie.x[i].style.top=YDummy[0];msie.x[i].style.left=XDummy[0];

msie.y[i].style.top=YDummy[1];msie.y[i].style.left=XDummy[1];

msie.z[i].style.top=YDummy[2];msie.z[i].style.left=XDummy[2];

}

}

}

setTimeout("prepos()",10);

}

function Start(){

swirl(),prepos()

}

window.onload=Start;

// --

/script

/body/html

跟随鼠标很逼真的弹性小球

html

head

title网页特效|Linkweb.cn/Js|---跟随鼠标很逼真的弹性小球/title

/headbody

!--将以下代码加入HTML的Body/Body之间--

DIV id=dot0

style="HEIGHT: 16; POSITION: absolute; VISIBILITY: hidden; WIDTH: 11; left:10; top:15"IMG

height=11 src="images/bullet.gif" width=11 /DIV

DIV id=dot1 style="HEIGHT: 11px; POSITION: absolute; WIDTH: 11px"IMG

height=11 src="images/bullet.gif" width=11 /DIV

DIV id=dot2 style="HEIGHT: 11px; POSITION: absolute; WIDTH: 11px"IMG

height=11 src="images/bullet.gif" width=11 /DIV

DIV id=dot3 style="HEIGHT: 11px; POSITION: absolute; WIDTH: 11px"IMG

height=11 src="images/bullet.gif" width=11 /DIV

DIV id=dot4 style="HEIGHT: 11px; POSITION: absolute; WIDTH: 11px"IMG

height=11 src="images/bullet.gif" width=11 /DIV

DIV id=dot5 style="HEIGHT: 11px; POSITION: absolute; WIDTH: 11px"IMG

height=11 src="images/bullet.gif" width=11 /DIV

DIV id=dot6 style="HEIGHT: 16; POSITION: absolute; WIDTH: 11; left:10; top:15"IMG

height=11 src="images/bullet.gif" width=11 /DIV

SCRIPT language=JavaScript

var nDots = 7;

var Xpos = 0;

var Ypos = 0;

var DELTAT = .01;

var SEGLEN = 10;

var SPRINGK = 10;

var MASS = 1;

var XGRAVITY = 0;

var YGRAVITY = 50;

var RESISTANCE = 10;

var STOPVEL = 0.1;

var STOPACC = 0.1;

var DOTSIZE = 11;

var BOUNCE = 0.75;

var isNetscape = navigator.appName=="Netscape";

var followmouse = true;

var dots = new Array();

init();

function init()

{

var i = 0;

for (i = 0; i nDots; i++) {

dots[i] = new dot(i);

}

if (!isNetscape) {

}

for (i = 0; i nDots; i++) {

dots[i].obj.left = dots[i].X;

dots[i].obj.top = dots[i].Y;

}

if (isNetscape) {

startanimate();

} else {

setTimeout("startanimate()", 1000);

}

}

function dot(i)

{

this.X = Xpos;

this.Y = Ypos;

this.dx = 0;

this.dy = 0;

if (isNetscape) {

this.obj = eval("document.dot" + i);

} else {

this.obj = eval("dot" + i + ".style");

}

}

function startanimate() {

setInterval("animate()", 20);

}

function setInitPositions(dots)

{

var startloc = document.all.tags("LI");

var i = 0;

for (i = 0; i startloc.length i (nDots - 1); i++) {

dots[i+1].X = startloc[i].offsetLeft

startloc[i].offsetParent.offsetLeft - DOTSIZE;

dots[i+1].Y = startloc[i].offsetTop +

startloc[i].offsetParent.offsetTop + 2*DOTSIZE;

}

dots[0].X = dots[1].X;

dots[0].Y = dots[1].Y - SEGLEN;

}

function MoveHandler(e)

{

Xpos = e.pageX;

Ypos = e.pageY;

return true;

}

function MoveHandlerIE() {

Xpos = window.event.x + document.body.scrollLeft;

Ypos = window.event.y + document.body.scrollTop;

}

if (isNetscape) {

document.captureEvents(Event.MOUSEMOVE);

document.onMouseMove = MoveHandler;

} else {

document.onmousemove = MoveHandlerIE;

}

function vec(X, Y)

{

this.X = X;

this.Y = Y;

}

function springForce(i, j, spring)

{

var dx = (dots[i].X - dots[j].X);

var dy = (dots[i].Y - dots[j].Y);

var len = Math.sqrt(dx*dx + dy*dy);

if (len SEGLEN) {

var springF = SPRINGK * (len - SEGLEN);

spring.X += (dx / len) * springF;

spring.Y += (dy / len) * springF;

}

}

function animate() {

var start = 0;

if (followmouse) {

dots[0].X = Xpos;

dots[0].Y = Ypos;

start = 1;

}

for (i = start ; i nDots; i++ ) {

var spring = new vec(0, 0);

if (i 0) {

springForce(i-1, i, spring);

}

if (i (nDots - 1)) {

springForce(i+1, i, spring);

}

var resist = new vec(-dots[i].dx * RESISTANCE,

-dots[i].dy * RESISTANCE);

var accel = new vec((spring.X + resist.X)/MASS + XGRAVITY,

(spring.Y + resist.Y)/ MASS + YGRAVITY);

dots[i].dx += (DELTAT * accel.X);

dots[i].dy += (DELTAT * accel.Y);

if (Math.abs(dots[i].dx) STOPVEL

Math.abs(dots[i].dy) STOPVEL

Math.abs(accel.X) STOPACC

Math.abs(accel.Y) STOPACC) {

dots[i].dx = 0;

dots[i].dy = 0;

}

dots[i].X += dots[i].dx;

dots[i].Y += dots[i].dy;

var height, width;

if (isNetscape) {

height = window.innerHeight + window.pageYOffset;

width = window.innerWidth + window.pageXOffset;

} else {

height = document.body.clientHeight + document.body.scrollTop;

width = document.body.clientWidth + document.body.scrollLeft;

}

if (dots[i].Y = height - DOTSIZE - 1) {

if (dots[i].dy 0) {

dots[i].dy = BOUNCE * -dots[i].dy;

}

dots[i].Y = height - DOTSIZE - 1;

}

if (dots[i].X = width - DOTSIZE) {

if (dots[i].dx 0) {

dots[i].dx = BOUNCE * -dots[i].dx;

}

dots[i].X = width - DOTSIZE - 1;

}

if (dots[i].X 0) {

if (dots[i].dx 0) {

dots[i].dx = BOUNCE * -dots[i].dx;

}

dots[i].X = 0;

}

dots[i].obj.left = dots[i].X;

dots[i].obj.top = dots[i].Y;

}

}

/SCRIPT

/body/html

这里太小了 放不了那么多

里面有很多的 不想链接的话 就看那两个吧

寻找漂亮网页效果的代码

网页效果代码集合

1。忽视右键

body oncontextmenu="return false"或body style="overflow-y:hidden"

2。加入背景音乐

IE:bgsound src="*.mid" loop=infinite

NS:embed src="*.mid" autostart=true hidden=true loop=true/embed

*.mid你的背景音乐的midi格式文件

3。简单的window.open方法

a href="#"

onclick="javascript:window.open('文件路径/文件名','newwindow',

'toolbar=no,scrollbars=yes,resizable=no,top=0,left=0,

width=400,height=300');"文字或图片/a

参数解释:

SCRIPT LANGUAGE="javascript" js脚本开始;

window.open 弹出新窗口的命令;

'文件路径/文件名'' 弹出窗口的文件名;

'newwindow' 弹出窗口的名字(不是文件名),非必须,可用空''代替;

width=400 窗口宽度;

height=300 窗口高度;

top=0 窗口距离屏幕上方的象素值;

left=0 窗口距离屏幕左侧的象素值;

toolbar=no 是否显示工具栏,yes为显示;

menubar,scrollbars 表示菜单栏和滚动栏。

resizable=no 是否允许改变窗口大小,yes为允许;

location=no 是否显示地址栏,yes为允许;

status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;

/SCRIPT js脚本结束

4。简单的页面加密

script LANGUAGE="JAVASCRIPT"

!--

function loopy(){

var sWord ="";

while(sWord!="login"){sWord=prompt("请输入你的登陆密码");}

alert("登陆成功!");

}

loopy()

//--

/script

5。拉动页面时背景图不动

style

body{background-image:url(logo.gif);

background-repeat:no-repeat;background-position:center}

/style

6。让浏览器在保存页面时保存失败

NOSCRIPTiframe src="*.html"/iframe/NOSCRIPT

7。随机替换图片

script

document.write('img src="img/'+parseInt(Math.random()*(5))

+'.gif"height="40" width="50"')

/script

图片文件名为0.gif 1.gif 2.gif 3.gif 4.gif

8。窗口定时关闭

先将如下代码网页文件的区:

script language="JavaScript"

function closeit() { setTimeout("self.close()",10000) //毫秒 }

/script

然后再在body标内加入如:body onload="closeit()"

9。网页自动关闭

html

head

object id=closes type="application/x-oleobject"

classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"

param name="Command" value="Close"

/object

/head

body onload="window.setTimeout('closes.Click()',10000)"

这个窗口会在10秒过后自动关闭,而且不会出现提示.

/body

/html

10。网页自动刷新

在head部记入

META HTTP-EQUIV="Refresh" content="20"

其中20为20秒后自动刷新,你可以更改为任意值。

11。网页自动转页

META HTTP-EQUIV="Refresh" CONTENT="时间(秒);URL=地址"

12。保持layer在最前面,而不被Iframe、Object所覆盖

在Layer中再插Iframe 或 Object 设z-Index值

div z-Index:2object xxx/object # 前面

div z-Index:1object xxx/object # 后面

div id="Layer2" style="position:absolute; top:40;width:400px;

height:95px;z-index:2" height=100% width=100%

iframe width=0 height=0/iframe

/div

div id="Layer1" style="position:absolute; top:50;width:200px;

height:115px;z-index:1"

iframe height=100% width=100%/iframe

/div

13。返回上一页

a href='javascript:history.back(1)'『返回上一页』/a

14。关闭窗口

a href='javascript:self.close()'『关闭窗口』/a

15。关于iframe的透明背景

IFRAME ID="iFrame1" SRC="iframe.htm"

allowTransparency="true"

STYLE="background-color: green"/IFRAME

(责任编辑:IT教学网)

更多

推荐CMS技巧文章