站长常用广告代码的表达大全
生活随笔
收集整理的這篇文章主要介紹了
站长常用广告代码的表达大全
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
【最基本的彈出窗口代碼】
其實代碼非常簡單:
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
window.open ('page.html')
-->
</SCRIPT>
因為這是一段Javascript代碼,所以它們應該放在<SCRIPT LANGUAGE ="javascript">標簽和</script>之間。<!--和-->是對一些版本低的瀏覽器起作用,在這些老瀏覽器中如果不支持Javascript,不會將標簽中的代碼作為文本顯示出來。
Window.open ('page.html')用于控制彈出新的窗口page.html,如果page.html不與主窗口在同一路徑下,前面應寫明路徑,絕對路徑([url]http://)[/url]和相對路徑(../)均可。
用單引號和雙引號都可以,只是不要混用。
這一段代碼可以加入HTML的任意位置,加入到<head>和</head>之間也可以,位置越靠前執(zhí)行越早,尤其是頁面代碼較長時,又想使頁面早點彈出就盡量往前放。
【經(jīng)過設置后的彈出窗口】
下面再說一說彈出窗口外觀的設置。只要再往上面的代碼中加一點東西就可以了。
我們來定制這個彈出窗口的外觀、尺寸大小、彈出位置以適應該頁面的具體情況。
<SCRIPT LANGUAGE="javascript:>
<!--
window.open ('page.html','newwindow','height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,
location=no,status=no')
//寫成一行
-->
</SCRIPT>
參數(shù)解釋:
<SCRIPT LANGUAGE="javascript"> js腳本開始;
window.open 彈出新窗口的命令;
page.html 彈出新窗口的文件名;
newwindow 彈出窗口的名字(不是文件名),可用空 ″代替;
height=100 窗口高度;
top=0 窗口距離屏幕上方的像素值;
left=0 窗口距離屏幕左側(cè)的像素值;
toolbar=no 是否顯示工具欄,yes為顯示;
menubar,scrollbars 表示菜單欄和滾動欄;
resizable=no 是否允許改變窗口大小,yes為允許;
location=no 是否顯示地址欄,yes為允許;
status=no 是否顯示狀態(tài)欄內(nèi)的信息(通常是文件已經(jīng)打開),yes為允許;
</SCRIPT> js腳本結(jié)束。
【用函數(shù)控制彈出窗口】
下面是一個完整的代碼。
<html>
<head>
<script LANGUAGE="JavaScript">
<!--
function openwin(){
window.open("page.html","newwindow","height=100,width=400,toolbar=no,menubar=no,scrollbars=no,resizable=no,
location=no,status=no")
//寫成一行
}
-->
</script>
</head>
<body οnlοad="openwin()">
...任意的頁面內(nèi)容...
</body>
</html>
這里定義了一個函數(shù)openwin(),函數(shù)內(nèi)容就是打開一個窗口。在調(diào)用它之前沒有任何用途。怎么調(diào)用呢?
方法一:<body οnlοad="openwen()"> 瀏覽器讀頁面時彈出窗口;
方法二:<body οnunlοad="openwen()"> 瀏覽器離開頁面時彈出窗口;
方法三:用一個連接調(diào)用:<a href="#" οnclick="openwin()">打開一個窗口</a>
注意:使用的"#"是虛連接。
方法四:用一個按鈕調(diào)用:<input type="button" οnclick="openwin()" value="打開窗口">
【主窗口打開文件1.htm,同時彈出小窗口page.html】
將如下代碼加入主窗口<head>區(qū):
<script language="javascript">
<!--
function openwin(){
window.open("page.html","","width=200,height=200")
}
//-->
</script>
加入<body>區(qū):<a href="1.htm" οnclick="openwin()">open</a>即可。
【彈出的窗口之定時關閉控制】
下面我們再對彈出窗口進行一些控制,效果就更好了。如果我們再將一小段代碼加入彈出的頁面(注意是加入到page.html的HTML中,可不是主頁面中,否則…),讓它在10秒鐘后自動關閉是不是更酷了?
首先,將如下代碼加入page.html文件的<head>區(qū):
<script language="JavaScript">
function closeit() {
setTimeout("self.close()",10000) //毫秒
}
</script>
然后,再用<body οnlοad="closeit()">這一句話代替page.html中原有的<BODY>這一句就可以了。(這一句話千萬不要忘記寫啊!這一句的作用是調(diào)用關閉窗口的代碼,10秒鐘后就自行關閉該窗口。)
【在彈出窗口中加上一個關閉按鈕】
<FORM>
<INPUT TYPE='BUTTON' VALUE='關閉' onClick='window.close()'>
</form>
呵呵,現(xiàn)在更加完美了!
【內(nèi)包含的彈出窗口——一個頁面兩個窗口】
上面的例子都包含兩個窗口,一個是主窗口,另一個是彈出的小窗口。
通過下面的例子,你可以在一個頁面內(nèi)完成上面的效果。
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function openwin()
{
OpenWindow=window.open("","newwin","height=250,width=250,toolbar=no,scrollbars="+scroll+",menubar=no");
//寫成一行
OpenWindow.document.write("<TITLE>例子</TITLE>")
OpenWindow.document.write("<BODY BGCOLOR=#FFFFFF>")
OpenWindow.document.write("<H1>Hello!</h1>")
OpenWindow.document.write("New window opened!")
OpenWindow.document.write("</BODY >")
OpenWindow.document.write("</HTML>")
OpenWindow.document.close()
}
</script>
</head>
<body>
<a href="#" οnclick="openwin()">打開一個窗口</a>
<input type="button" οnclick="openwin()" value="打開窗口">
</body>? ?
</html>
看看OpenWindow.document.write()里面的代碼不就是標準的HTML嗎?只要按照格式寫更多的行即可。千萬注意多一個標簽或少一個標簽都會出現(xiàn)錯誤。記住用OpenWindow.document.close()結(jié)束啊。
【終極應用——彈出窗口的Cookie控制】
回想一下,上面的彈出窗口雖然酷,但是有一點小毛病(你沉浸在喜悅之中,一定沒有發(fā)現(xiàn)吧?)比如你將上面的腳本放在一個需要頻繁經(jīng)過的頁面里(例如首頁),那么每次刷新這個頁面,窗口都會彈出一次,是不是非常煩人?有解決的辦法嗎?Yes!Follow me。我們使用Cookie來控制一下就可以了。
首先,將如下代碼加入主頁面HTML的<HEAD>區(qū):
<script>
function openwin(){
window.open("page.html","","width=200,height=200")
}
function get_cookie(Name){
var search = Name+ "="
var returnvalue ="";
if (document.cookie.length >0){
offset = document.cookie.indexOf(search)
if (offset!=-1){
offset += search.length
end = document.cookie.indexOf (";",offset);
if (end ==-1)
end = document.cookie.length;
returnvalue =unescape(document.cookie.substring(offset,end))
}
}
return returnvalue;
}
function loadpopup(){
if (get_cookie('popped')=="){
openwin()
document.cookie="popped=yes"
}
}
</script>
然后,用<body οnlοad="loadpopup()">(注意不是openwin 而是loadpop啊)替換主頁面中原有的<BODY>這一句即可。你可以試著刷新一下這個頁面或重新進入該頁面,窗口再也不會彈出了。真正的Pop-Only-Once!
寫到這里,彈出窗口的制作和應用技巧基本上算是講完了,希望對正在制作網(wǎng)頁的朋友有所幫助我就非常欣慰了。
需要注意的是,JS腳本中的大小寫最好前后保持一致。
a 關閉跳出窗口代碼:
<script language="JavaScript">
<!--
var exit=true;
function ext()
{
if (exit)
window.open ('http://www.qqee.com');
}
//-->? ?? ?? ?? ?</script>
<body οnunlοad="ext()">
b??禁止另存代碼;
<NOSCRIPT><IFRAME SRC=*.html></IFRAME></NOSCRIPT>
c 最大化窗口
<script??language="JavaScript">??
self.moveTo(0,0)??
self.resizeTo(screen.availWidth,screen.availHeight)??
</script>
d 幀頁
<IFRAME SRC="guanggao/kan88_guanbi.htm" WIDTH="0" HEIGHT="0" MARGINWIDTH="0" MARGINHEIGHT="0" HSPACE="0" VSPACE="0" FRAMEBORDER="0" SCROLLING="no"></IFRAME>
e 跳出廣告
<script language="JavaScript"><!--
function opencolortext(){
window.open('http://www.ccfilm.com/)
}
setTimeout("opencolortext()",10000)
// --></script>
10000 表示十秒后彈出 (但實際在六七秒左右彈出)
f 跳出 默認當前頁面
<SCRIPT language=javascript> window.open ('http://vv11.com', '_new', 'height=500, width=600, top=0, left=0, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=yes');window.focus()</SCRIPT>
1、收藏本站
??說明 點擊即可把你的網(wǎng)站添加到瀏覽器的收藏菜單下
??代碼
<span style="CURSOR: hand" onClick="window.external.addFavorite('http://www.66xx.com','站長信息網(wǎng)')" title="搜索網(wǎng)">收藏本站</span>
2、設為首頁
??說明 點擊即可把你的網(wǎng)站設置為瀏覽器的起始頁??
??代碼
<span οnclick="var strHref=window.location.href;this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.66xx.com');" style="CURSOR: hand">設為首頁</span>
3、自動關閉窗口
??說明 在網(wǎng)頁源代碼中加入下面的代碼,則該窗口將在20秒鐘之后自動關閉!這與跳出式小窗口配合使用是再好不過啦!代碼中“i=20”表示關閉的延遲時間為20秒,可任意修改。??
??代碼
<script language="javascript">
<!--
function clock(){i=i-1
document.title="本窗口將在"+i+"秒后自動關閉!";
if(i>0)setTimeout("clock();",1000);
else self.close();}
var i=20
clock();
//-->
</script>
4、跳出小窗口
??說明 在打開有下面這段代碼的頁面時將會跳出一個468x60大小的小窗口。“window.html”為跳出的小窗口里所要顯示的網(wǎng)頁。toolbar、status、menubar、scrollbars、設置小窗口的工具欄、狀態(tài)欄、菜單欄及滾動條的有無,resizable設置是否可讓瀏覽者改變小窗口大小,width、height設置小窗口的寬度以及高度。(不過這樣的小窗口一般是不受歡迎的哦!)??
??代碼
<script language="JavaScript">
window.open("window.html","www_helpor_net","toolbar=no, status=no,menubar=no, scrollbars=no,resizable=no,width=468,height=60,left=200,top=50");
</script>
5、固定字號大小
??說明 你是否有過這樣的經(jīng)歷:一個布置得很好的網(wǎng)頁,當瀏覽時把瀏覽器的字號設置成大或小時,漂亮的網(wǎng)頁馬上面目全非了。因為字的大小變了,版式自然亂了。現(xiàn)在好了,只要把下面這段代碼加入到網(wǎng)頁源文件的<head>與</head>之間就行了(對用<font>標簽定義的文字無效)。
??代碼
<style type="text/css">
<!--
body {font-size:9pt}
td {font-size:9pt}
-->
</style>
6、文本自動向上循環(huán)滾動
??說明: 文本自動向上循環(huán)滾動,鼠標放到上面還會暫時停下來。??
??代碼:
<table border="1" bordercolor="#000000" bgcolor="#6699ff" cellpadding="5" cellspacing="0">
<tr>
<td>
<script language=javascript>
document.write ("<marquee scrollamount='1' scrolldelay='30' direction= 'UP' width='200' id='helpor_net' height='150' οnmοuseοver='helpor_net.stop()' οnmοuseοut='helpor_net.start()' Author:redriver; For more,visit:[url]www.helpor.net[/url]>")
document.write ("<h2><p align='center'><font color='#ffffff' face='黑體'>偶 然</font></h2>")
document.write ("<p align='right'><a href='#' target='_blank'><font color='#ffffff'>徐志摩</font></a> ")
document.write ("<p><font color='#ffffff'> ")
document.write ("<br>我是天空里的一片云,")
document.write ("<br>偶爾投影在你的波心?? ")
document.write ("<br>你不必訝異, ")
document.write ("<br>更無須歡喜?? ")
document.write ("<br>在轉(zhuǎn)瞬間消滅了蹤影。")
document.write ("<br>")
document.write ("<br>你我相逢在黑暗的海上,")
document.write ("<br>你有你的,我有我的,方向;")
document.write ("<br>你記得也好, ")
document.write ("<br>最好你忘掉, ")
document.write ("<br>在這交會時互放的光亮! ")
document.write ("</font>")
document.write ("</marquee> ")
</script>
</td>
</tr>
</table>
7、舞臺光柱照射的效果??
??說明: 頁面產(chǎn)生舞臺光柱照射的效果??
??代碼:
<body bgcolor="#000000" id="www_helpor_net" style="position: relative; left: 0px; color: White; filter: light">
<script language="VBScript">
Option Explicit
sub window_OnLoad()
call www_helpor_net.filters.light(0).addambient(0,0,255,30)
call www_helpor_net.filters.light(0).addcone(400,400,200,100,100,200,204,200,80,10)
end sub
sub document_onMouseMove()
call www_helpor_net.filters.light(0).MoveLight(1,window.event.x,window.event.y,0,1)
end sub
</script>
8、百頁窗的效果
??說明 進入頁面時,頁面產(chǎn)生百頁窗似的的效果
??代碼
<style>
<!--
.helpor_net{position:absolute;
left:0;
top:0;
layer-background-color:#3399ff;
background-color:#3399ff;
border:0.1px solid green
}
-->
</style>
<div id="i1" class="helpor_net"></div><div id="i2" class="helpor_net"></div><div id="i3"
class="helpor_net"></div><div id="i4" class="helpor_net"></div><div id="i5" class="helpor_net"></div><div
id="i6" class="helpor_net"></div><div id="i7" class="helpor_net"></div><div id="i8" class="helpor_net"></div>
<SCRIPT language=javascript>
<!--
var speed=30
var temp=new Array()
var temp2=new Array()
if (document.layers){
for (i=1;i<=8;i++){
temp[i]=eval("document.i"+i+".clip")
temp2[i]=eval("document.i"+i)
temp[i].width=window.innerWidth/8-0.3
temp[i].height=window.innerHeight
temp2[i].left=(i-1)*temp[i].width
}
}
else if (document.all){
var clipbottom=document.body.offsetHeight,cliptop=0
for (i=1;i<=8;i++){
temp[i]=eval("document.all.i"+i+".style")
temp[i].width=document.body.clientWidth/8
temp[i].height=document.body.offsetHeight
temp[i].left=(i-1)*parseInt(temp[i].width)
}
}
function openit(){
window.scrollTo(0,0)
if (document.layers){
for (i=1;i<=8;i=i+2)
temp[i].bottom-=speed
for (i=2;i<=8;i=i+2)
temp[i].top+=speed
if (temp[2].top>window.innerHeight)
clearInterval(stopit)
}
else if (document.all){
clipbottom-=speed
for (i=1;i<=8;i=i+2){
temp[i].clip="rect(0 auto+"+clipbottom+" 0)"
}
cliptop+=speed
for (i=2;i<=8;i=i+2){
temp[i].clip="rect("+cliptop+" auto auto)"
}
if (clipbottom<=0)
clearInterval(stopit)
}
}
function www_helpor_net(){
stopit=setInterval("openit()",100)
}
www_helpor_net()
-->
</SCRIPT>
9、文本自動向上循環(huán)滾動
??說明: 文本自動向上循環(huán)滾動,鼠標放到上面還會暫時停下來。
??代碼:
<DIV class=ttl1 id=ttl0><SPAN class=ttl1></SPAN></DIV>
<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');
}
//以下是輸出的內(nèi)容,自己修改即可。
var dispStr = new Array(
"<font color=red size=3>歡迎光臨...</font>"
);
var overMe=0;
function helpor_net(str, idx, idObj, spObj, clr1, clr2, delay, plysnd) {
var tmp0 = tmp1 = '', skip = 0;
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+"</font><font color='"+clr2+"'>"+tmp1+"</font></span>");
setTimeout("helpor_net('"+str+"', "+idx+", '"+idObj+"', '"+spObj+"', '"+clr1+"', '"+clr2+"', "+delay+" ,"+plysnd+")",delay);
}
}
function www_helpor_net() {
helpor_net(dispStr[0], 0, 'ttl0', 'ttl1', '#339933', '#99FF33', 50, 0);
}
www_helpor_net();
// -->
</SCRIPT>
10、字符慢慢隱現(xiàn)??
??說明: 字符慢慢隱現(xiàn)
??代碼:
<body bgcolor="#FFFFFF" id="www_helpor_net">
<div id="helpor_net" style="visibility:visible;width:400px;height:30px;text-align:center; font-family:隸書;font-size:30pt;color:6699ff"></div>
<SCRIPT language="JavaScript">
<!--
var thissize=20
var textfont="隸書"
var textcolor= new Array()
textcolor[0]="000000"
textcolor[1]="000000"
textcolor[2]="000000"
textcolor[3]="111111"
textcolor[4]="222222"
textcolor[5]="333333"
textcolor[6]="444444"
textcolor[7]="555555"
textcolor[8]="666666"
textcolor[9]="777777"
textcolor[10]="888888"
textcolor[11]="999999"
textcolor[12]="aaaaaa"
textcolor[13]="bbbbbb"
textcolor[14]="cccccc"
textcolor[15]="dddddd"
textcolor[16]="eeeeee"
textcolor[17]="ffffff"
textcolor[18]="ffffff"
var message = new Array()
message[0]="歡迎光臨、、、、、、"
message[1]="多停留一會兒"
message[2]="你會有更多的收獲"
message[3]="請再次光臨"
i_message=0
var i_strength=0
var i_message=0
var timer
function www_helpor_net() {
if(document.all) {
if (i_strength <=17) {
helpor_net.innerText=message[i_message]
document.all.helpor_net.style.filter="glow(color="+textcolor[i_strength]+", strength=4)"
i_strength++
timer=setTimeout("www_helpor_net()",100)
}
else {
clearTimeout(timer)
setTimeout("dewww_helpor_net()",1500)
}
}
}
function dewww_helpor_net() {
if(document.all) {
if (i_strength >=0) {
helpor_net.innerText=message[i_message]
document.all.helpor_net.style.filter="glow(color="+textcolor[i_strength]+", strength=4)"
i_strength--
timer=setTimeout("dewww_helpor_net()",100)
}
else {
clearTimeout(timer)
i_message++
if (i_message>=message.length) {i_message=0}
i_strength=0
intermezzo()
}
}
}
function intermezzo() {
helpor_net.innerText=""
setTimeout("www_helpor_net()",1000)
}
www_helpor_net();
//-->
</SCRIPT>
11、文字從天而降
??說明: 文字從頁面頂部掉下來??
??代碼:
<p www_helpor_net="dropWord" style="position: relative !important; left: 10000 !important" align="center"><font size="3" color="#ee00FF">哇! 有 沒 有 嚇 著 你 啊 ?</font><font size="7" face="Arial" color="#FF0000"><b>YES!</b></font></p>
<SCRIPT language="JavaScript">
<!--
dynamicanimAttr = "www_helpor_net"
animateElements = new Array()
currentElement = 0
speed = 0
stepsZoom = 8
stepsWord = 8
stepsFly = 12
stepsSpiral = 16
steps = stepsZoom
step = 0
outString = ""
function helpor_net()
{
var ms = navigator.appVersion.indexOf("MSIE")
ie4 = (ms>0) && (parseInt(navigator.appVersion.substring(ms+5, ms+6)) >= 4)
if(!ie4)
{
if((navigator.appName == "Netscape") &&
(parseInt(navigator.appVersion.substring(0, 1)) >= 4))
{
for (index=document.layers.length-1; index >= 0; index--)
{
layer=document.layers[index]
if (layer.left==10000)
layer.left=0
}
}
return
}
for (index=document.all.length-1; index >= document.body.sourceIndex; index--)
{
el = document.all[index]
animation = el.getAttribute(dynamicanimAttr, false)
if(null != animation)
{
if(animation == "dropWord" animation == "flyTopRightWord" animation == "flyBottomRightWord")
{
ih = el.innerHTML
outString = ""
i1 = 0
iend = ih.length
while(true)
{
i2 = startWord(ih, i1)
if(i2 == -1)
i2 = iend
outWord(ih, i1, i2, false, "")
if(i2 == iend)
break
i1 = i2
i2 = endWord(ih, i1)
if(i2 == -1)
i2 = iend
outWord(ih, i1, i2, true, animation)
if(i2 == iend)
break
i1 = i2
}
document.all[index].innerHTML = outString
document.all[index].style.posLeft = 0
document.all[index].setAttribute(dynamicanimAttr, null)
}
if(animation == "zoomIn" animation == "zoomOut")
{
ih = el.innerHTML
outString = "<SPAN " + dynamicanimAttr + "=\"" + animation + "\" style=\"position: relative; left: 10000;\">"
outString += ih
outString += "</SPAN>"
document.all[index].innerHTML = outString
document.all[index].style.posLeft = 0
document.all[index].setAttribute(dynamicanimAttr, null)
}
}
}
i = 0
for (index=document.body.sourceIndex; index < document.all.length; index++)
{
el = document.all[index]
animation = el.getAttribute(dynamicanimAttr, false)
if (null != animation)
{
if(animation == "flyLeft")
{
el.style.posLeft = 10000-offsetLeft(el)-el.offsetWidth
el.style.posTop = 0
}
else if(animation == "flyRight")
{
el.style.posLeft = 10000-offsetLeft(el)+document.body.offsetWidth
el.style.posTop = 0
}
else if(animation == "flyTop" animation == "dropWord")
{
el.style.posLeft = 0
el.style.posTop = document.body.scrollTop-offsetTop(el)-el.offsetHeight
}
else if(animation == "flyBottom")
{
el.style.posLeft = 0
el.style.posTop = document.body.scrollTop-offsetTop(el)+document.body.offsetHeight
}
else if(animation == "flyTopLeft")
{
el.style.posLeft = 10000-offsetLeft(el)-el.offsetWidth
el.style.posTop = document.body.scrollTop-offsetTop(el)-el.offsetHeight
}
else if(animation == "flyTopRight" animation == "flyTopRightWord")
{
el.style.posLeft = 10000-offsetLeft(el)+document.body.offsetWidth
el.style.posTop = document.body.scrollTop-offsetTop(el)-el.offsetHeight
}
else if(animation == "flyBottomLeft")
{
el.style.posLeft = 10000-offsetLeft(el)-el.offsetWidth
el.style.posTop = document.body.scrollTop-offsetTop(el)+document.body.offsetHeight
}
else if(animation == "flyBottomRight" animation == "flyBottomRightWord")
{
el.style.posLeft = 10000-offsetLeft(el)+document.body.offsetWidth
el.style.posTop = document.body.scrollTop-offsetTop(el)+document.body.offsetHeight
}
else if(animation == "spiral")
{
el.style.posLeft = 10000-offsetLeft(el)-el.offsetWidth
el.style.posTop = document.body.scrollTop-offsetTop(el)-el.offsetHeight
}
else if(animation == "zoomIn")
{
el.style.posLeft = 10000
el.style.posTop = 0
}
else if(animation == "zoomOut")
{
el.style.posLeft = 10000
el.style.posTop = 0
}
else
{
el.style.posLeft = 10000-offsetLeft(el)-el.offsetWidth
el.style.posTop = 0
}
el.initLeft = el.style.posLeft
el.initTop = el.style.posTop
animateElements[i++] = el
}
}
window.setTimeout("animate();", speed)
}
function offsetLeft(el)
{
x = el.offsetLeft
for (e = el.offsetParent; e; e = e.offsetParent)
x += e.offsetLeft;
return x
}
function offsetTop(el)
{
y = el.offsetTop
for (e = el.offsetParent; e; e = e.offsetParent)
y += e.offsetTop;
return y
}
function startWord(ih, i)
{
for(tag = false; i < ih.length; i++)
{
c = ih.charAt(i)
if(c == '<')
tag = true
if(!tag)
return i
if(c == '>')
tag = false
}
return -1
}
function endWord(ih, i)
{
nonSpace = false
space = false
while(i < ih.length)
{
c = ih.charAt(i)
if(c != ' ')
nonSpace = true
if(nonSpace && c == ' ')
space = true
if(c == '<')
return i
if(space && c != ' ')
return i
i++
}
return -1
}
function outWord(ih, i1, i2, dyn, anim)
{
if(dyn)
outString += "<SPAN " + dynamicanimAttr + "=\"" + anim + "\" style=\"position: relative; left: 10000;\">"
outString += ih.substring(i1, i2)
if(dyn)
outString += "</SPAN>"
}
function animate()
{
el = animateElements[currentElement]
animation = el.getAttribute(dynamicanimAttr, false)
step++
if(animation == "spiral")
{
steps = stepsSpiral
v = step/steps
rf = 1.0 - v
t = v * 2.0*Math.PI
rx = Math.max(Math.abs(el.initLeft), 200)
ry = Math.max(Math.abs(el.initTop), 200)
el.style.posLeft = Math.ceil(-rf*Math.cos(t)*rx)
el.style.posTop = Math.ceil(-rf*Math.sin(t)*ry)
}
else if(animation == "zoomIn")
{
steps = stepsZoom
el.style.fontSize = Math.ceil(50+50*step/steps) + "%"
el.style.posLeft = 0
}
else if(animation == "zoomOut")
{
steps = stepsZoom
el.style.fontSize = Math.ceil(100+200*(steps-step)/steps) + "%"
el.style.posLeft = 0
}
else
{
steps = stepsFly
if(animation == "dropWord" animation == "flyTopRightWord" animation == "flyBottomRightWord")
steps = stepsWord
dl = el.initLeft / steps
dt = el.initTop / steps
el.style.posLeft = el.style.posLeft - dl
el.style.posTop = el.style.posTop - dt
}
if (step >= steps)
{
el.style.posLeft = 0
el.style.posTop = 0
currentElement++
step = 0
}
if(currentElement < animateElements.length)
window.setTimeout("animate();", speed)
}
helpor_net()
//-->
</SCRIPT>
12、百頁窗效果
??說明: 進入頁面時,頁面產(chǎn)生百頁窗似的的效果
??代碼:
<style>
<!--
.helpor_net{position:absolute;
left:0;
top:0;
layer-background-color:#3399ff;
background-color:#3399ff;
border:0.1px solid green
}
-->
</style>
<div id="i1" class="helpor_net"></div><div id="i2" class="helpor_net"></div><div id="i3"
class="helpor_net"></div><div id="i4" class="helpor_net"></div><div id="i5" class="helpor_net"></div><div
id="i6" class="helpor_net"></div><div id="i7" class="helpor_net"></div><div id="i8" class="helpor_net"></div>
<SCRIPT language=javascript>
<!--
var speed=30
var temp=new Array()
var temp2=new Array()
if (document.layers){
for (i=1;i<=8;i++){
temp[i]=eval("document.i"+i+".clip")
temp2[i]=eval("document.i"+i)
temp[i].width=window.innerWidth/8-0.3
temp[i].height=window.innerHeight
temp2[i].left=(i-1)*temp[i].width
}
}
else if (document.all){
var clipbottom=document.body.offsetHeight,cliptop=0
for (i=1;i<=8;i++){
temp[i]=eval("document.all.i"+i+".style")
temp[i].width=document.body.clientWidth/8
temp[i].height=document.body.offsetHeight
temp[i].left=(i-1)*parseInt(temp[i].width)
}
}
function openit(){
window.scrollTo(0,0)
if (document.layers){
for (i=1;i<=8;i=i+2)
temp[i].bottom-=speed
for (i=2;i<=8;i=i+2)
temp[i].top+=speed
if (temp[2].top>window.innerHeight)
clearInterval(stopit)
}
else if (document.all){
clipbottom-=speed
for (i=1;i<=8;i=i+2){
temp[i].clip="rect(0 auto+"+clipbottom+" 0)"
}
cliptop+=speed
for (i=2;i<=8;i=i+2){
temp[i].clip="rect("+cliptop+" auto auto)"
}
if (clipbottom<=0)
clearInterval(stopit)
}
}
function www_helpor_net(){
stopit=setInterval("openit()",100)
}
www_helpor_net()
-->
</SCRIPT>
13、有滾動的文字說明??
??說明:鼠標放到鏈接上就會出現(xiàn)一個說明框,里面有滾動的文字說明
??代碼:
<a href="http://www.helpor.net" target="_blank" onMouseOver="helpor_net_show(this,event,'看到了吧?')" onMouseOut="helpor_net_hide()">把鼠標放上來試試</a>
<div id="tooltip2" style="position:absolute;visibility:hidden;clip:rect(0 150 50 0);width:150px;background-color:seashell">
<layer name="nstip" width="1000px" bgColor="seashell"></layer>
</div>
<SCRIPT language="JavaScript">
<!--
if (!document.layers&&!document.all)
event="test"
function helpor_net_show(current,e,text){
if (document.all&&document.readyState=="complete"){
document.all.tooltip2.innerHTML='<marquee style="border:1px solid #3399ff">'+text+'</marquee>'
document.all.tooltip2.style.pixelLeft=event.clientX+document.body.scrollLeft+10
document.all.tooltip2.style.pixelTop=event.clientY+document.body.scrollTop+10
document.all.tooltip2.style.visibility="visible"
}
else if (document.layers){
document.tooltip2.document.nstip.document.write('<b>'+text+'</b>')
document.tooltip2.document.nstip.document.close()
document.tooltip2.document.nstip.left=0
currentscroll=setInterval("scrolltip()",100)
document.tooltip2.left=e.pageX+10
document.tooltip2.top=e.pageY+10
document.tooltip2.visibility="show"
}
}
function helpor_net_hide(){
if (document.all)
document.all.tooltip2.style.visibility="hidden"
else if (document.layers){
clearInterval(currentscroll)
document.tooltip2.visibility="hidden"
}
}
function scrolltip(){
if (document.tooltip2.document.nstip.left>=-document.tooltip2.document.nstip.document.width)
document.tooltip2.document.nstip.left-=5
else
document.tooltip2.document.nstip.left=150
}
//-->
</SCRIPT>
14、圖片跟隨著鼠標
??說明:圖片跟隨著鼠標,最好把圖片做成透明的,那樣效果更好
??代碼:
<SCRIPT LANGUAGE="JavaScript">
var image="../images/helpor.gif"
var newtop=15
var newleft=15
if (navigator.appName == "Netscape") {
layerStyleRef="layer.";
layerRef="document.layers";
styleSwitch="";
}
else
{
layerStyleRef="layer.style.";
layerRef="document.all";
styleSwitch=".style";
}
function helpor_net() {
layerName = 'iit'
eval('var curElement='+layerRef+'["'+layerName+'"]')
eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"')
eval('curElement'+styleSwitch+'.visibility="visible"')
eval('newleft=document.body.clientWidth-curElement'+styleSwitch+'.pixelWidth')
eval('newtop=document.body.clientHeight-curElement'+styleSwitch+'.pixelHeight')
eval('height=curElement'+styleSwitch+'.height')
eval('width=curElement'+styleSwitch+'.width')
width=parseInt(width)
height=parseInt(height)
if (event.clientX > (document.body.clientWidth - 5 - width))
{
newleft=document.body.clientWidth + document.body.scrollLeft - 5 - width
}
else
{
newleft=document.body.scrollLeft + event.clientX
}
eval('curElement'+styleSwitch+'.pixelLeft=newleft')
if (event.clientY > (document.body.clientHeight - 5 - height))
{
newtop=document.body.clientHeight + document.body.scrollTop - 5 - height
}
else
{
newtop=document.body.scrollTop + event.clientY
}
eval('curElement'+styleSwitch+'.pixelTop=newtop')
}
document.onmousemove = helpor_net;
if (navigator.appName == "Netscape") {
}
else
{
document.write('<div ID="OuterDiv">')
document.write('<img ID="iit" src="'+image+'" STYLE="position:absolute;TOP:20pt;LEFT:20pt;Z-INDEX:20;visibility:hidden;">')
document.write('</div>')
}
</script>??
15、飄動的字符跟鼠標
??說明 在鼠標后面跟著一串飄動的字符??
??代碼
<style type="text/css">
.spanstyle {
COLOR: #00cccc; FONT-FAMILY: 宋體; FONT-SIZE: 10pt; POSITION: absolute; TOP: -50px; VISIBILITY: visible
}
</style>
<script>
var x,y
var step=18
var flag=0
var message="★歡迎你的光臨!"
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]=-200
}
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 www_helpor_net() {
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("www_helpor_net()",30)
}
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;
www_helpor_net();
// -->
</script>
16、數(shù)字時鐘
??說明 數(shù)字化的時鐘
??代碼
<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"+minutes
if(seconds<=9)
seconds="0"+seconds
myclock="現(xiàn)在時刻:<font size='5' face='Arial black'>"+hours+":"+minutes+":"+seconds+"</font>"
if(document.layers){document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}else if(document.all)
liveclock.innerHTML=myclock
setTimeout("www_helpor_net()",1000)
}
www_helpor_net();
//-->
</SCRIPT>
17、六種風格時間
??說明: 六種風格時間顯示,一定有你喜歡的!
??效果: 風格一: 星期二,6月1日,2004年
??風格二: 7:56:28上午
??風格三: 星期二,6月1日,2004年 7:56:28上午
??風格四: 6/1/04
??風格五: 7:56:28
??風格六: Tue Jun 1 07:56:28 UTC+0800 2004
??代碼:
<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>
18、顯示停留的時間
??說明: 顯示他人在頁面停留的時間,而且可以作出提醒??
??代碼:
您在本站逗留了<input type="text" name="helpor_net" size="15" style="border: 0 ">
<SCRIPT language="javascript">
<!--
var sec=0;
var min=0;
var hou=0;
flag=0;
idt=window.setTimeout("www_helpor_net();",1000);
function www_helpor_net()
{
sec++;
if(sec==60){sec=0;min+=1;}
if(min==60){min=0;hou+=1;}
if((min>0)&&(flag==0))
{
window.alert("您剛剛來了1分鐘!可別急著走開,還有好多好東東等著您呢!--站長");
flag=1;
}
helpor_net.value=hou+"小時"+min+"分"+sec+"秒";
idt=window.setTimeout("www_helpor_net();",1000);
}
//-->
</SCRIPT>
19、有影子的數(shù)字時鐘
??說明: 這個時鐘是有影子的,而且還在不停地走著呢??
??代碼:
<div id="bgclockshade" style="position:absolute;visibility:visible;font-family:'Arial black';color:#cccccc;font-size:20px;top:50px;left:173px"></div>
<div id="bgclocknoshade" style="position:absolute;visibility:visible;font-family:'Arial black';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+":"+seconds
if(document.all) {
bgclocknoshade.innerHTML=thistime
bgclockshade.innerHTML=thistime
}
if(document.layers) {
document.bgclockshade.document.write('<div id="bgclockshade" style="position:absolute;visibility:visible;font-family:Verdana;color:FFAAAAA;font-size:20px;top:10px;left:152px">'+thistime+'</div>')
document.bgclocknoshade.document.write('<div id="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>
20、全中文日期顯示
??說明: 年月日都是用全中文顯示
??代碼:
<script language="JavaScript">
<!--
function number(index1){
var numberstring="一二三四五六七八九十";
if(index1 ==0) {document.write("十")}
if(index1 < 10){
document.write(numberstring.substring(0+(index1-1),index1))}
else if(index1 < 20 ){
document.write("十"+numberstring.substring(0+(index1-11),(index1-10)))}
else if(index1 < 30 ){
document.write("二十"+numberstring.substring(0+(index1-21),(index1-20)))}
else{
document.write("三十"+numberstring.substring(0+(index1-31),(index1-30)))}
}
var today1 = new Date()
var month = today1.getMonth()+1
var date = today1.getDate()
var day = today1.getDay()
document.write("公元二零零三年")
number(month)
document.write("月")
number(date)
document.write("日")
//-->
</script>
21、打字效果
??說明: 文字在狀態(tài)欄上從左往右一個一個地顯示,就象你打出的字一樣??
??代碼: <script language="JavaScript">
var msg = "歡迎光臨,請多提意見。謝謝! " ;
var interval = 120
var spacelen = 120;
var space10=" ";
var seq=0;
function Helpor_net() {
len = msg.length;
window.status = msg.substring(0, seq+1);
seq++;
if ( seq >= len ) {
seq = 0;
window.status = '';
window.setTimeout("Helpor_net();", interval );
}
else
window.setTimeout("Helpor_net();", interval );
}
Helpor_net();
</script>
22、文字從左往右移動
??說明: 文字在狀態(tài)欄上從右往左顯示,而且是循環(huán)的??
??代碼:
<script>
<!--
function Helpor_net(seed)
{ var m1 = "歡迎來到網(wǎng)頁特效世界,請多提意見。謝謝! !" ;
var m2 = "" ;
var msg=m1+m2;
var out = " ";
var c = 1;
var speed = 120;
if (seed > 100)
{ seed-=2;
var cmd="Helpor_net(" + seed + ")";
timerTwo=window.setTimeout(cmd,speed);}
else if (seed <= 100 && seed > 0)
{ for (c=0 ; c < seed ; c++)
{ out+=" ";}
out+=msg; seed-=2;
var cmd="Helpor_net(" + seed + ")";
window.status=out;
timerTwo=window.setTimeout(cmd,speed); }
else if (seed <= 0)
{ if (-seed < msg.length)
{
out+=msg.substring(-seed,msg.length);
seed-=2;
var cmd="Helpor_net(" + seed + ")";
window.status=out;
timerTwo=window.setTimeout(cmd,speed);}
else { window.status=" ";
timerTwo=window.setTimeout("Helpor_net(100)",speed);
}
}
}
Helpor_net(100);
-->
</script>
23、圖像自動變化
??說明: 把一張圖片變形扭曲成各種不同的長寬,非常好玩??
??代碼:
<img src="http://code.helpor.net/picture/swimming.gif" name="u" border="1" alt="很好玩的">
<script language="JavaScript">
var b = 1;
var c = true;
function www_helpor_net(){
if(document.all);
if(c == true) {
b++;
}
if(b==100) {
b--;
c = false
}
if(b==10) {
b++;
c = true;
}
if(c == false) {
b--;
}
u.width=150 + b;
u.height=125 - b;
setTimeout("www_helpor_net()",50);
}
www_helpor_net();
</script>
24、漫天飛雪
??說明: 漫天飛雪
??代碼:
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
var no = 12;
var speed = 10;
var heart = "http://code.helpor.net/picture/snow.gif";
var flag;
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 800, doc_height = 600;
if (ns4up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx = new Array();
xp = new Array();
yp = new Array();
amx = new Array();
amy = new Array();
stx = new Array();
sty = new Array();
flag = new Array();
for (i = 0; i < no; ++ i) {
dx[i] = 0; // set coordinate variables
xp[i] = Math.random()*(doc_width-30)+10;
yp[i] = Math.random()*doc_height;
amy[i] = 12+ Math.random()*20;
amx[i] = 10+ Math.random()*40;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
flag[i] = (Math.random()>0.5)?1:0;
if (ns4up) { // set layers
if (i == 0) {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");
document.write("top=\"15\" visibility=\"show\"><img src=\"");
document.write(heart+ "\" border=\"0\"></layer>");
} else {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");
document.write("top=\"15\" visibility=\"show\"><img src=\"");
document.write(heart+ "\" border=\"0\"></layer>");
}
} else
if (ie4up) {
if (i == 0) {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");
document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");
document.write(heart+ "\" border=\"0\"></div>");
} else {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");
document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");
document.write(heart+ "\" border=\"0\"></div>");
}
}
}
function helpor_net() {
for (i = 0; i < no; ++ i) {
if (yp[i] > doc_height-50) {
xp[i] = 10+ Math.random()*(doc_width-amx[i]-30);
yp[i] = 0;
flag[i]=(Math.random()<0.5)?1:0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
if (flag[i])
dx[i] += stx[i];
else
dx[i] -= stx[i];
if (Math.abs(dx[i]) > Math.PI) {
yp[i]+=Math.abs(amy[i]*dx[i]);
xp[i]+=amx[i]*dx[i];
dx[i]=0;
flag[i]=!flag[i];
}
document.layers["dot"+i].top = yp[i] + amy[i]*(Math.abs(Math.sin(dx[i])+dx[i]));
document.layers["dot"+i].left = xp[i] + amx[i]*dx[i];
}
setTimeout("helpor_net()", speed);
}
function www_helpor_net() {
for (i = 0; i < no; ++ i) {
if (yp[i] > doc_height-50) {
xp[i] = 10+ Math.random()*(doc_width-amx[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
flag[i]=(Math.random()<0.5)?1:0;
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
if (flag[i])
dx[i] += stx[i];
else
dx[i] -= stx[i];
if (Math.abs(dx[i]) > Math.PI) {
yp[i]+=Math.abs(amy[i]*dx[i]);
xp[i]+=amx[i]*dx[i];
dx[i]=0;
flag[i]=!flag[i];
}
document.all["dot"+i].style.pixelTop = yp[i] + amy[i]*(Math.abs(Math.sin(dx[i])+dx[i]));
document.all["dot"+i].style.pixelLeft = xp[i] + amx[i]*dx[i];
}
setTimeout("www_helpor_net()", speed);
}
if (ns4up) {
helpor_net();
} else if (ie4up) {
www_helpor_net();
}
//-->
</script>
25、圖片漸漸顯隱
??說明: 圖片漸漸顯隱
??代碼: <img src="http://code.helpor.net/picture/swimming.gif" name="u" border="1" style="filter:alpha(opacity=0)">
<script language="JavaScript">
var b = 1;
var c = true;
function helpor_net(){
if(document.all);
if(c == true) {
b++;
}
if(b==100) {
b--;
c = false
}
if(b==10) {
b++;
c = true;
}
if(c == false) {
b--;
}
u.filters.alpha.opacity=0 + b;
setTimeout("helpor_net()",50);
}
helpor_net();
</script>
26、圖片漸漸顯示
??說明: 圖片漸漸顯示
??代碼:
<img src="http://code.helpor.net/picture/swimming.gif" border="1" id="helpor_net" style="visibility:hidden; FILTER:revealTrans(Duration=4.0, Transition=23);">
<SCRIPT FOR="window" EVENT="onLoad" LANGUAGE="vbscript">
helpor_net.filters.item(0).apply()
helpor_net.filters.item(0).transition = 12
helpor_net.Style.visibility = ""
helpor_net.filters(0).play(2.0)
</SCRIPT>
27、自由移動的圖片??
??說明: 自由移動的圖片
??效果: 看到了嗎?
??代碼:
<div id="helpor_net" style="position:absolute; visibility:visible; left:0px; top:0px; z-index:-1">
<img src="http://code.helpor.net/picture/swimming.gif" border="0">
</div>
<SCRIPT LANGUAGE="JavaScript">
<!--
var isNS = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4));
var _all = '';
var _style = '';
var wwidth, wheight;
var ydir = '++';
var xdir = '++';
var id1, id2, id3;
var x = 1;
var y = 1;
var x1, y1;
if(!isNS) {
_all='all.';
_style='.style';
}
function www_helpor_net() {
clearTimeout(id1);
clearTimeout(id2);
clearTimeout(id3);
if (isNS) {
wwidth = window.innerWidth - 55;
wheight = window.innerHeight - 50;
} else {
wwidth = document.body.clientWidth - 55;
wheight = document.body.clientHeight - 50;
}
id3 = setTimeout('randomdir()', 20000);
animate();
}
function randomdir() {
if (Math.floor(Math.random()*2)) {
(Math.floor(Math.random()*2)) ? xdir='--': xdir='++';
} else {
(Math.floor(Math.random()*2)) ? ydir='--': ydir='++';
}
id2 = setTimeout('randomdir()', 20000);
}
function animate() {
eval('x'+xdir);
eval('y'+ydir);
if (isNS) {
helpor_net.moveTo((x+pageXOffset),(y+pageYOffset))
} else {
helpor_net.pixelLeft = x+document.body.scrollLeft;
helpor_net.pixelTop = y+document.body.scrollTop;
}
if (isNS) {
if (helpor_net.top <= 5+pageYOffset) ydir = '++';
if (helpor_net.top >= wheight+pageYOffset) ydir = '--';
if (helpor_net.left >= wwidth+pageXOffset) xdir = '--';
if (helpor_net.left <= 5+pageXOffset) xdir = '++';
} else {
if (helpor_net.pixelTop <= 5+document.body.scrollTop) ydir = '++';
if (helpor_net.pixelTop >= wheight+document.body.scrollTop) ydir = '--';
if (helpor_net.pixelLeft >= wwidth+document.body.scrollLeft) xdir = '--';
if (helpor_net.pixelLeft <= 5+document.body.scrollLeft) xdir = '++';
}
id1 = setTimeout('animate()', 30);
}
var helpor_net=eval('document.'+_all+'helpor_net'+_style);
// -->
</script>
再把<body>改為:
<body OnLoad="www_helpor_net()" OnResize="www_helpor_net()">
28、隨鼠標觸動而變化
??說明: 鼠標接觸或者離開圖片時,圖片大小會相應變化??
??代碼:
<span id="s1" style = "width : 150"><a href="http://www.helpor.net" target="_blank" οnmοuseοver="www_helpor_net.style.width='200';" οnmοuseοut="www_helpor_net.style.width= '150';"><Img src="http://code.helpor.net/picture/swimming.gif" id="www_helpor_net"></a></span>
29、javascript的容錯腳本
??說明: javascript的容錯腳本,有了它,你的頁面就不會出現(xiàn)錯誤提示了。??
??代碼:
<SCRIPT LANGUAGE="JavaScript">
<!--
function Helpor_net() {
return true;
}
window.onerror = Helpor_net();
// -->
</SCRIPT>
其實代碼非常簡單:
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
window.open ('page.html')
-->
</SCRIPT>
因為這是一段Javascript代碼,所以它們應該放在<SCRIPT LANGUAGE ="javascript">標簽和</script>之間。<!--和-->是對一些版本低的瀏覽器起作用,在這些老瀏覽器中如果不支持Javascript,不會將標簽中的代碼作為文本顯示出來。
Window.open ('page.html')用于控制彈出新的窗口page.html,如果page.html不與主窗口在同一路徑下,前面應寫明路徑,絕對路徑([url]http://)[/url]和相對路徑(../)均可。
用單引號和雙引號都可以,只是不要混用。
這一段代碼可以加入HTML的任意位置,加入到<head>和</head>之間也可以,位置越靠前執(zhí)行越早,尤其是頁面代碼較長時,又想使頁面早點彈出就盡量往前放。
【經(jīng)過設置后的彈出窗口】
下面再說一說彈出窗口外觀的設置。只要再往上面的代碼中加一點東西就可以了。
我們來定制這個彈出窗口的外觀、尺寸大小、彈出位置以適應該頁面的具體情況。
<SCRIPT LANGUAGE="javascript:>
<!--
window.open ('page.html','newwindow','height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,
location=no,status=no')
//寫成一行
-->
</SCRIPT>
參數(shù)解釋:
<SCRIPT LANGUAGE="javascript"> js腳本開始;
window.open 彈出新窗口的命令;
page.html 彈出新窗口的文件名;
newwindow 彈出窗口的名字(不是文件名),可用空 ″代替;
height=100 窗口高度;
top=0 窗口距離屏幕上方的像素值;
left=0 窗口距離屏幕左側(cè)的像素值;
toolbar=no 是否顯示工具欄,yes為顯示;
menubar,scrollbars 表示菜單欄和滾動欄;
resizable=no 是否允許改變窗口大小,yes為允許;
location=no 是否顯示地址欄,yes為允許;
status=no 是否顯示狀態(tài)欄內(nèi)的信息(通常是文件已經(jīng)打開),yes為允許;
</SCRIPT> js腳本結(jié)束。
【用函數(shù)控制彈出窗口】
下面是一個完整的代碼。
<html>
<head>
<script LANGUAGE="JavaScript">
<!--
function openwin(){
window.open("page.html","newwindow","height=100,width=400,toolbar=no,menubar=no,scrollbars=no,resizable=no,
location=no,status=no")
//寫成一行
}
-->
</script>
</head>
<body οnlοad="openwin()">
...任意的頁面內(nèi)容...
</body>
</html>
這里定義了一個函數(shù)openwin(),函數(shù)內(nèi)容就是打開一個窗口。在調(diào)用它之前沒有任何用途。怎么調(diào)用呢?
方法一:<body οnlοad="openwen()"> 瀏覽器讀頁面時彈出窗口;
方法二:<body οnunlοad="openwen()"> 瀏覽器離開頁面時彈出窗口;
方法三:用一個連接調(diào)用:<a href="#" οnclick="openwin()">打開一個窗口</a>
注意:使用的"#"是虛連接。
方法四:用一個按鈕調(diào)用:<input type="button" οnclick="openwin()" value="打開窗口">
【主窗口打開文件1.htm,同時彈出小窗口page.html】
將如下代碼加入主窗口<head>區(qū):
<script language="javascript">
<!--
function openwin(){
window.open("page.html","","width=200,height=200")
}
//-->
</script>
加入<body>區(qū):<a href="1.htm" οnclick="openwin()">open</a>即可。
【彈出的窗口之定時關閉控制】
下面我們再對彈出窗口進行一些控制,效果就更好了。如果我們再將一小段代碼加入彈出的頁面(注意是加入到page.html的HTML中,可不是主頁面中,否則…),讓它在10秒鐘后自動關閉是不是更酷了?
首先,將如下代碼加入page.html文件的<head>區(qū):
<script language="JavaScript">
function closeit() {
setTimeout("self.close()",10000) //毫秒
}
</script>
然后,再用<body οnlοad="closeit()">這一句話代替page.html中原有的<BODY>這一句就可以了。(這一句話千萬不要忘記寫啊!這一句的作用是調(diào)用關閉窗口的代碼,10秒鐘后就自行關閉該窗口。)
【在彈出窗口中加上一個關閉按鈕】
<FORM>
<INPUT TYPE='BUTTON' VALUE='關閉' onClick='window.close()'>
</form>
呵呵,現(xiàn)在更加完美了!
【內(nèi)包含的彈出窗口——一個頁面兩個窗口】
上面的例子都包含兩個窗口,一個是主窗口,另一個是彈出的小窗口。
通過下面的例子,你可以在一個頁面內(nèi)完成上面的效果。
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function openwin()
{
OpenWindow=window.open("","newwin","height=250,width=250,toolbar=no,scrollbars="+scroll+",menubar=no");
//寫成一行
OpenWindow.document.write("<TITLE>例子</TITLE>")
OpenWindow.document.write("<BODY BGCOLOR=#FFFFFF>")
OpenWindow.document.write("<H1>Hello!</h1>")
OpenWindow.document.write("New window opened!")
OpenWindow.document.write("</BODY >")
OpenWindow.document.write("</HTML>")
OpenWindow.document.close()
}
</script>
</head>
<body>
<a href="#" οnclick="openwin()">打開一個窗口</a>
<input type="button" οnclick="openwin()" value="打開窗口">
</body>? ?
</html>
看看OpenWindow.document.write()里面的代碼不就是標準的HTML嗎?只要按照格式寫更多的行即可。千萬注意多一個標簽或少一個標簽都會出現(xiàn)錯誤。記住用OpenWindow.document.close()結(jié)束啊。
【終極應用——彈出窗口的Cookie控制】
回想一下,上面的彈出窗口雖然酷,但是有一點小毛病(你沉浸在喜悅之中,一定沒有發(fā)現(xiàn)吧?)比如你將上面的腳本放在一個需要頻繁經(jīng)過的頁面里(例如首頁),那么每次刷新這個頁面,窗口都會彈出一次,是不是非常煩人?有解決的辦法嗎?Yes!Follow me。我們使用Cookie來控制一下就可以了。
首先,將如下代碼加入主頁面HTML的<HEAD>區(qū):
<script>
function openwin(){
window.open("page.html","","width=200,height=200")
}
function get_cookie(Name){
var search = Name+ "="
var returnvalue ="";
if (document.cookie.length >0){
offset = document.cookie.indexOf(search)
if (offset!=-1){
offset += search.length
end = document.cookie.indexOf (";",offset);
if (end ==-1)
end = document.cookie.length;
returnvalue =unescape(document.cookie.substring(offset,end))
}
}
return returnvalue;
}
function loadpopup(){
if (get_cookie('popped')=="){
openwin()
document.cookie="popped=yes"
}
}
</script>
然后,用<body οnlοad="loadpopup()">(注意不是openwin 而是loadpop啊)替換主頁面中原有的<BODY>這一句即可。你可以試著刷新一下這個頁面或重新進入該頁面,窗口再也不會彈出了。真正的Pop-Only-Once!
寫到這里,彈出窗口的制作和應用技巧基本上算是講完了,希望對正在制作網(wǎng)頁的朋友有所幫助我就非常欣慰了。
需要注意的是,JS腳本中的大小寫最好前后保持一致。
a 關閉跳出窗口代碼:
<script language="JavaScript">
<!--
var exit=true;
function ext()
{
if (exit)
window.open ('http://www.qqee.com');
}
//-->? ?? ?? ?? ?</script>
<body οnunlοad="ext()">
b??禁止另存代碼;
<NOSCRIPT><IFRAME SRC=*.html></IFRAME></NOSCRIPT>
c 最大化窗口
<script??language="JavaScript">??
self.moveTo(0,0)??
self.resizeTo(screen.availWidth,screen.availHeight)??
</script>
d 幀頁
<IFRAME SRC="guanggao/kan88_guanbi.htm" WIDTH="0" HEIGHT="0" MARGINWIDTH="0" MARGINHEIGHT="0" HSPACE="0" VSPACE="0" FRAMEBORDER="0" SCROLLING="no"></IFRAME>
e 跳出廣告
<script language="JavaScript"><!--
function opencolortext(){
window.open('http://www.ccfilm.com/)
}
setTimeout("opencolortext()",10000)
// --></script>
10000 表示十秒后彈出 (但實際在六七秒左右彈出)
f 跳出 默認當前頁面
<SCRIPT language=javascript> window.open ('http://vv11.com', '_new', 'height=500, width=600, top=0, left=0, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=yes');window.focus()</SCRIPT>
1、收藏本站
??說明 點擊即可把你的網(wǎng)站添加到瀏覽器的收藏菜單下
??代碼
<span style="CURSOR: hand" onClick="window.external.addFavorite('http://www.66xx.com','站長信息網(wǎng)')" title="搜索網(wǎng)">收藏本站</span>
2、設為首頁
??說明 點擊即可把你的網(wǎng)站設置為瀏覽器的起始頁??
??代碼
<span οnclick="var strHref=window.location.href;this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.66xx.com');" style="CURSOR: hand">設為首頁</span>
3、自動關閉窗口
??說明 在網(wǎng)頁源代碼中加入下面的代碼,則該窗口將在20秒鐘之后自動關閉!這與跳出式小窗口配合使用是再好不過啦!代碼中“i=20”表示關閉的延遲時間為20秒,可任意修改。??
??代碼
<script language="javascript">
<!--
function clock(){i=i-1
document.title="本窗口將在"+i+"秒后自動關閉!";
if(i>0)setTimeout("clock();",1000);
else self.close();}
var i=20
clock();
//-->
</script>
4、跳出小窗口
??說明 在打開有下面這段代碼的頁面時將會跳出一個468x60大小的小窗口。“window.html”為跳出的小窗口里所要顯示的網(wǎng)頁。toolbar、status、menubar、scrollbars、設置小窗口的工具欄、狀態(tài)欄、菜單欄及滾動條的有無,resizable設置是否可讓瀏覽者改變小窗口大小,width、height設置小窗口的寬度以及高度。(不過這樣的小窗口一般是不受歡迎的哦!)??
??代碼
<script language="JavaScript">
window.open("window.html","www_helpor_net","toolbar=no, status=no,menubar=no, scrollbars=no,resizable=no,width=468,height=60,left=200,top=50");
</script>
5、固定字號大小
??說明 你是否有過這樣的經(jīng)歷:一個布置得很好的網(wǎng)頁,當瀏覽時把瀏覽器的字號設置成大或小時,漂亮的網(wǎng)頁馬上面目全非了。因為字的大小變了,版式自然亂了。現(xiàn)在好了,只要把下面這段代碼加入到網(wǎng)頁源文件的<head>與</head>之間就行了(對用<font>標簽定義的文字無效)。
??代碼
<style type="text/css">
<!--
body {font-size:9pt}
td {font-size:9pt}
-->
</style>
6、文本自動向上循環(huán)滾動
??說明: 文本自動向上循環(huán)滾動,鼠標放到上面還會暫時停下來。??
??代碼:
<table border="1" bordercolor="#000000" bgcolor="#6699ff" cellpadding="5" cellspacing="0">
<tr>
<td>
<script language=javascript>
document.write ("<marquee scrollamount='1' scrolldelay='30' direction= 'UP' width='200' id='helpor_net' height='150' οnmοuseοver='helpor_net.stop()' οnmοuseοut='helpor_net.start()' Author:redriver; For more,visit:[url]www.helpor.net[/url]>")
document.write ("<h2><p align='center'><font color='#ffffff' face='黑體'>偶 然</font></h2>")
document.write ("<p align='right'><a href='#' target='_blank'><font color='#ffffff'>徐志摩</font></a> ")
document.write ("<p><font color='#ffffff'> ")
document.write ("<br>我是天空里的一片云,")
document.write ("<br>偶爾投影在你的波心?? ")
document.write ("<br>你不必訝異, ")
document.write ("<br>更無須歡喜?? ")
document.write ("<br>在轉(zhuǎn)瞬間消滅了蹤影。")
document.write ("<br>")
document.write ("<br>你我相逢在黑暗的海上,")
document.write ("<br>你有你的,我有我的,方向;")
document.write ("<br>你記得也好, ")
document.write ("<br>最好你忘掉, ")
document.write ("<br>在這交會時互放的光亮! ")
document.write ("</font>")
document.write ("</marquee> ")
</script>
</td>
</tr>
</table>
7、舞臺光柱照射的效果??
??說明: 頁面產(chǎn)生舞臺光柱照射的效果??
??代碼:
<body bgcolor="#000000" id="www_helpor_net" style="position: relative; left: 0px; color: White; filter: light">
<script language="VBScript">
Option Explicit
sub window_OnLoad()
call www_helpor_net.filters.light(0).addambient(0,0,255,30)
call www_helpor_net.filters.light(0).addcone(400,400,200,100,100,200,204,200,80,10)
end sub
sub document_onMouseMove()
call www_helpor_net.filters.light(0).MoveLight(1,window.event.x,window.event.y,0,1)
end sub
</script>
8、百頁窗的效果
??說明 進入頁面時,頁面產(chǎn)生百頁窗似的的效果
??代碼
<style>
<!--
.helpor_net{position:absolute;
left:0;
top:0;
layer-background-color:#3399ff;
background-color:#3399ff;
border:0.1px solid green
}
-->
</style>
<div id="i1" class="helpor_net"></div><div id="i2" class="helpor_net"></div><div id="i3"
class="helpor_net"></div><div id="i4" class="helpor_net"></div><div id="i5" class="helpor_net"></div><div
id="i6" class="helpor_net"></div><div id="i7" class="helpor_net"></div><div id="i8" class="helpor_net"></div>
<SCRIPT language=javascript>
<!--
var speed=30
var temp=new Array()
var temp2=new Array()
if (document.layers){
for (i=1;i<=8;i++){
temp[i]=eval("document.i"+i+".clip")
temp2[i]=eval("document.i"+i)
temp[i].width=window.innerWidth/8-0.3
temp[i].height=window.innerHeight
temp2[i].left=(i-1)*temp[i].width
}
}
else if (document.all){
var clipbottom=document.body.offsetHeight,cliptop=0
for (i=1;i<=8;i++){
temp[i]=eval("document.all.i"+i+".style")
temp[i].width=document.body.clientWidth/8
temp[i].height=document.body.offsetHeight
temp[i].left=(i-1)*parseInt(temp[i].width)
}
}
function openit(){
window.scrollTo(0,0)
if (document.layers){
for (i=1;i<=8;i=i+2)
temp[i].bottom-=speed
for (i=2;i<=8;i=i+2)
temp[i].top+=speed
if (temp[2].top>window.innerHeight)
clearInterval(stopit)
}
else if (document.all){
clipbottom-=speed
for (i=1;i<=8;i=i+2){
temp[i].clip="rect(0 auto+"+clipbottom+" 0)"
}
cliptop+=speed
for (i=2;i<=8;i=i+2){
temp[i].clip="rect("+cliptop+" auto auto)"
}
if (clipbottom<=0)
clearInterval(stopit)
}
}
function www_helpor_net(){
stopit=setInterval("openit()",100)
}
www_helpor_net()
-->
</SCRIPT>
9、文本自動向上循環(huán)滾動
??說明: 文本自動向上循環(huán)滾動,鼠標放到上面還會暫時停下來。
??代碼:
<DIV class=ttl1 id=ttl0><SPAN class=ttl1></SPAN></DIV>
<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');
}
//以下是輸出的內(nèi)容,自己修改即可。
var dispStr = new Array(
"<font color=red size=3>歡迎光臨...</font>"
);
var overMe=0;
function helpor_net(str, idx, idObj, spObj, clr1, clr2, delay, plysnd) {
var tmp0 = tmp1 = '', skip = 0;
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+"</font><font color='"+clr2+"'>"+tmp1+"</font></span>");
setTimeout("helpor_net('"+str+"', "+idx+", '"+idObj+"', '"+spObj+"', '"+clr1+"', '"+clr2+"', "+delay+" ,"+plysnd+")",delay);
}
}
function www_helpor_net() {
helpor_net(dispStr[0], 0, 'ttl0', 'ttl1', '#339933', '#99FF33', 50, 0);
}
www_helpor_net();
// -->
</SCRIPT>
10、字符慢慢隱現(xiàn)??
??說明: 字符慢慢隱現(xiàn)
??代碼:
<body bgcolor="#FFFFFF" id="www_helpor_net">
<div id="helpor_net" style="visibility:visible;width:400px;height:30px;text-align:center; font-family:隸書;font-size:30pt;color:6699ff"></div>
<SCRIPT language="JavaScript">
<!--
var thissize=20
var textfont="隸書"
var textcolor= new Array()
textcolor[0]="000000"
textcolor[1]="000000"
textcolor[2]="000000"
textcolor[3]="111111"
textcolor[4]="222222"
textcolor[5]="333333"
textcolor[6]="444444"
textcolor[7]="555555"
textcolor[8]="666666"
textcolor[9]="777777"
textcolor[10]="888888"
textcolor[11]="999999"
textcolor[12]="aaaaaa"
textcolor[13]="bbbbbb"
textcolor[14]="cccccc"
textcolor[15]="dddddd"
textcolor[16]="eeeeee"
textcolor[17]="ffffff"
textcolor[18]="ffffff"
var message = new Array()
message[0]="歡迎光臨、、、、、、"
message[1]="多停留一會兒"
message[2]="你會有更多的收獲"
message[3]="請再次光臨"
i_message=0
var i_strength=0
var i_message=0
var timer
function www_helpor_net() {
if(document.all) {
if (i_strength <=17) {
helpor_net.innerText=message[i_message]
document.all.helpor_net.style.filter="glow(color="+textcolor[i_strength]+", strength=4)"
i_strength++
timer=setTimeout("www_helpor_net()",100)
}
else {
clearTimeout(timer)
setTimeout("dewww_helpor_net()",1500)
}
}
}
function dewww_helpor_net() {
if(document.all) {
if (i_strength >=0) {
helpor_net.innerText=message[i_message]
document.all.helpor_net.style.filter="glow(color="+textcolor[i_strength]+", strength=4)"
i_strength--
timer=setTimeout("dewww_helpor_net()",100)
}
else {
clearTimeout(timer)
i_message++
if (i_message>=message.length) {i_message=0}
i_strength=0
intermezzo()
}
}
}
function intermezzo() {
helpor_net.innerText=""
setTimeout("www_helpor_net()",1000)
}
www_helpor_net();
//-->
</SCRIPT>
11、文字從天而降
??說明: 文字從頁面頂部掉下來??
??代碼:
<p www_helpor_net="dropWord" style="position: relative !important; left: 10000 !important" align="center"><font size="3" color="#ee00FF">哇! 有 沒 有 嚇 著 你 啊 ?</font><font size="7" face="Arial" color="#FF0000"><b>YES!</b></font></p>
<SCRIPT language="JavaScript">
<!--
dynamicanimAttr = "www_helpor_net"
animateElements = new Array()
currentElement = 0
speed = 0
stepsZoom = 8
stepsWord = 8
stepsFly = 12
stepsSpiral = 16
steps = stepsZoom
step = 0
outString = ""
function helpor_net()
{
var ms = navigator.appVersion.indexOf("MSIE")
ie4 = (ms>0) && (parseInt(navigator.appVersion.substring(ms+5, ms+6)) >= 4)
if(!ie4)
{
if((navigator.appName == "Netscape") &&
(parseInt(navigator.appVersion.substring(0, 1)) >= 4))
{
for (index=document.layers.length-1; index >= 0; index--)
{
layer=document.layers[index]
if (layer.left==10000)
layer.left=0
}
}
return
}
for (index=document.all.length-1; index >= document.body.sourceIndex; index--)
{
el = document.all[index]
animation = el.getAttribute(dynamicanimAttr, false)
if(null != animation)
{
if(animation == "dropWord" animation == "flyTopRightWord" animation == "flyBottomRightWord")
{
ih = el.innerHTML
outString = ""
i1 = 0
iend = ih.length
while(true)
{
i2 = startWord(ih, i1)
if(i2 == -1)
i2 = iend
outWord(ih, i1, i2, false, "")
if(i2 == iend)
break
i1 = i2
i2 = endWord(ih, i1)
if(i2 == -1)
i2 = iend
outWord(ih, i1, i2, true, animation)
if(i2 == iend)
break
i1 = i2
}
document.all[index].innerHTML = outString
document.all[index].style.posLeft = 0
document.all[index].setAttribute(dynamicanimAttr, null)
}
if(animation == "zoomIn" animation == "zoomOut")
{
ih = el.innerHTML
outString = "<SPAN " + dynamicanimAttr + "=\"" + animation + "\" style=\"position: relative; left: 10000;\">"
outString += ih
outString += "</SPAN>"
document.all[index].innerHTML = outString
document.all[index].style.posLeft = 0
document.all[index].setAttribute(dynamicanimAttr, null)
}
}
}
i = 0
for (index=document.body.sourceIndex; index < document.all.length; index++)
{
el = document.all[index]
animation = el.getAttribute(dynamicanimAttr, false)
if (null != animation)
{
if(animation == "flyLeft")
{
el.style.posLeft = 10000-offsetLeft(el)-el.offsetWidth
el.style.posTop = 0
}
else if(animation == "flyRight")
{
el.style.posLeft = 10000-offsetLeft(el)+document.body.offsetWidth
el.style.posTop = 0
}
else if(animation == "flyTop" animation == "dropWord")
{
el.style.posLeft = 0
el.style.posTop = document.body.scrollTop-offsetTop(el)-el.offsetHeight
}
else if(animation == "flyBottom")
{
el.style.posLeft = 0
el.style.posTop = document.body.scrollTop-offsetTop(el)+document.body.offsetHeight
}
else if(animation == "flyTopLeft")
{
el.style.posLeft = 10000-offsetLeft(el)-el.offsetWidth
el.style.posTop = document.body.scrollTop-offsetTop(el)-el.offsetHeight
}
else if(animation == "flyTopRight" animation == "flyTopRightWord")
{
el.style.posLeft = 10000-offsetLeft(el)+document.body.offsetWidth
el.style.posTop = document.body.scrollTop-offsetTop(el)-el.offsetHeight
}
else if(animation == "flyBottomLeft")
{
el.style.posLeft = 10000-offsetLeft(el)-el.offsetWidth
el.style.posTop = document.body.scrollTop-offsetTop(el)+document.body.offsetHeight
}
else if(animation == "flyBottomRight" animation == "flyBottomRightWord")
{
el.style.posLeft = 10000-offsetLeft(el)+document.body.offsetWidth
el.style.posTop = document.body.scrollTop-offsetTop(el)+document.body.offsetHeight
}
else if(animation == "spiral")
{
el.style.posLeft = 10000-offsetLeft(el)-el.offsetWidth
el.style.posTop = document.body.scrollTop-offsetTop(el)-el.offsetHeight
}
else if(animation == "zoomIn")
{
el.style.posLeft = 10000
el.style.posTop = 0
}
else if(animation == "zoomOut")
{
el.style.posLeft = 10000
el.style.posTop = 0
}
else
{
el.style.posLeft = 10000-offsetLeft(el)-el.offsetWidth
el.style.posTop = 0
}
el.initLeft = el.style.posLeft
el.initTop = el.style.posTop
animateElements[i++] = el
}
}
window.setTimeout("animate();", speed)
}
function offsetLeft(el)
{
x = el.offsetLeft
for (e = el.offsetParent; e; e = e.offsetParent)
x += e.offsetLeft;
return x
}
function offsetTop(el)
{
y = el.offsetTop
for (e = el.offsetParent; e; e = e.offsetParent)
y += e.offsetTop;
return y
}
function startWord(ih, i)
{
for(tag = false; i < ih.length; i++)
{
c = ih.charAt(i)
if(c == '<')
tag = true
if(!tag)
return i
if(c == '>')
tag = false
}
return -1
}
function endWord(ih, i)
{
nonSpace = false
space = false
while(i < ih.length)
{
c = ih.charAt(i)
if(c != ' ')
nonSpace = true
if(nonSpace && c == ' ')
space = true
if(c == '<')
return i
if(space && c != ' ')
return i
i++
}
return -1
}
function outWord(ih, i1, i2, dyn, anim)
{
if(dyn)
outString += "<SPAN " + dynamicanimAttr + "=\"" + anim + "\" style=\"position: relative; left: 10000;\">"
outString += ih.substring(i1, i2)
if(dyn)
outString += "</SPAN>"
}
function animate()
{
el = animateElements[currentElement]
animation = el.getAttribute(dynamicanimAttr, false)
step++
if(animation == "spiral")
{
steps = stepsSpiral
v = step/steps
rf = 1.0 - v
t = v * 2.0*Math.PI
rx = Math.max(Math.abs(el.initLeft), 200)
ry = Math.max(Math.abs(el.initTop), 200)
el.style.posLeft = Math.ceil(-rf*Math.cos(t)*rx)
el.style.posTop = Math.ceil(-rf*Math.sin(t)*ry)
}
else if(animation == "zoomIn")
{
steps = stepsZoom
el.style.fontSize = Math.ceil(50+50*step/steps) + "%"
el.style.posLeft = 0
}
else if(animation == "zoomOut")
{
steps = stepsZoom
el.style.fontSize = Math.ceil(100+200*(steps-step)/steps) + "%"
el.style.posLeft = 0
}
else
{
steps = stepsFly
if(animation == "dropWord" animation == "flyTopRightWord" animation == "flyBottomRightWord")
steps = stepsWord
dl = el.initLeft / steps
dt = el.initTop / steps
el.style.posLeft = el.style.posLeft - dl
el.style.posTop = el.style.posTop - dt
}
if (step >= steps)
{
el.style.posLeft = 0
el.style.posTop = 0
currentElement++
step = 0
}
if(currentElement < animateElements.length)
window.setTimeout("animate();", speed)
}
helpor_net()
//-->
</SCRIPT>
12、百頁窗效果
??說明: 進入頁面時,頁面產(chǎn)生百頁窗似的的效果
??代碼:
<style>
<!--
.helpor_net{position:absolute;
left:0;
top:0;
layer-background-color:#3399ff;
background-color:#3399ff;
border:0.1px solid green
}
-->
</style>
<div id="i1" class="helpor_net"></div><div id="i2" class="helpor_net"></div><div id="i3"
class="helpor_net"></div><div id="i4" class="helpor_net"></div><div id="i5" class="helpor_net"></div><div
id="i6" class="helpor_net"></div><div id="i7" class="helpor_net"></div><div id="i8" class="helpor_net"></div>
<SCRIPT language=javascript>
<!--
var speed=30
var temp=new Array()
var temp2=new Array()
if (document.layers){
for (i=1;i<=8;i++){
temp[i]=eval("document.i"+i+".clip")
temp2[i]=eval("document.i"+i)
temp[i].width=window.innerWidth/8-0.3
temp[i].height=window.innerHeight
temp2[i].left=(i-1)*temp[i].width
}
}
else if (document.all){
var clipbottom=document.body.offsetHeight,cliptop=0
for (i=1;i<=8;i++){
temp[i]=eval("document.all.i"+i+".style")
temp[i].width=document.body.clientWidth/8
temp[i].height=document.body.offsetHeight
temp[i].left=(i-1)*parseInt(temp[i].width)
}
}
function openit(){
window.scrollTo(0,0)
if (document.layers){
for (i=1;i<=8;i=i+2)
temp[i].bottom-=speed
for (i=2;i<=8;i=i+2)
temp[i].top+=speed
if (temp[2].top>window.innerHeight)
clearInterval(stopit)
}
else if (document.all){
clipbottom-=speed
for (i=1;i<=8;i=i+2){
temp[i].clip="rect(0 auto+"+clipbottom+" 0)"
}
cliptop+=speed
for (i=2;i<=8;i=i+2){
temp[i].clip="rect("+cliptop+" auto auto)"
}
if (clipbottom<=0)
clearInterval(stopit)
}
}
function www_helpor_net(){
stopit=setInterval("openit()",100)
}
www_helpor_net()
-->
</SCRIPT>
13、有滾動的文字說明??
??說明:鼠標放到鏈接上就會出現(xiàn)一個說明框,里面有滾動的文字說明
??代碼:
<a href="http://www.helpor.net" target="_blank" onMouseOver="helpor_net_show(this,event,'看到了吧?')" onMouseOut="helpor_net_hide()">把鼠標放上來試試</a>
<div id="tooltip2" style="position:absolute;visibility:hidden;clip:rect(0 150 50 0);width:150px;background-color:seashell">
<layer name="nstip" width="1000px" bgColor="seashell"></layer>
</div>
<SCRIPT language="JavaScript">
<!--
if (!document.layers&&!document.all)
event="test"
function helpor_net_show(current,e,text){
if (document.all&&document.readyState=="complete"){
document.all.tooltip2.innerHTML='<marquee style="border:1px solid #3399ff">'+text+'</marquee>'
document.all.tooltip2.style.pixelLeft=event.clientX+document.body.scrollLeft+10
document.all.tooltip2.style.pixelTop=event.clientY+document.body.scrollTop+10
document.all.tooltip2.style.visibility="visible"
}
else if (document.layers){
document.tooltip2.document.nstip.document.write('<b>'+text+'</b>')
document.tooltip2.document.nstip.document.close()
document.tooltip2.document.nstip.left=0
currentscroll=setInterval("scrolltip()",100)
document.tooltip2.left=e.pageX+10
document.tooltip2.top=e.pageY+10
document.tooltip2.visibility="show"
}
}
function helpor_net_hide(){
if (document.all)
document.all.tooltip2.style.visibility="hidden"
else if (document.layers){
clearInterval(currentscroll)
document.tooltip2.visibility="hidden"
}
}
function scrolltip(){
if (document.tooltip2.document.nstip.left>=-document.tooltip2.document.nstip.document.width)
document.tooltip2.document.nstip.left-=5
else
document.tooltip2.document.nstip.left=150
}
//-->
</SCRIPT>
14、圖片跟隨著鼠標
??說明:圖片跟隨著鼠標,最好把圖片做成透明的,那樣效果更好
??代碼:
<SCRIPT LANGUAGE="JavaScript">
var image="../images/helpor.gif"
var newtop=15
var newleft=15
if (navigator.appName == "Netscape") {
layerStyleRef="layer.";
layerRef="document.layers";
styleSwitch="";
}
else
{
layerStyleRef="layer.style.";
layerRef="document.all";
styleSwitch=".style";
}
function helpor_net() {
layerName = 'iit'
eval('var curElement='+layerRef+'["'+layerName+'"]')
eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"')
eval('curElement'+styleSwitch+'.visibility="visible"')
eval('newleft=document.body.clientWidth-curElement'+styleSwitch+'.pixelWidth')
eval('newtop=document.body.clientHeight-curElement'+styleSwitch+'.pixelHeight')
eval('height=curElement'+styleSwitch+'.height')
eval('width=curElement'+styleSwitch+'.width')
width=parseInt(width)
height=parseInt(height)
if (event.clientX > (document.body.clientWidth - 5 - width))
{
newleft=document.body.clientWidth + document.body.scrollLeft - 5 - width
}
else
{
newleft=document.body.scrollLeft + event.clientX
}
eval('curElement'+styleSwitch+'.pixelLeft=newleft')
if (event.clientY > (document.body.clientHeight - 5 - height))
{
newtop=document.body.clientHeight + document.body.scrollTop - 5 - height
}
else
{
newtop=document.body.scrollTop + event.clientY
}
eval('curElement'+styleSwitch+'.pixelTop=newtop')
}
document.onmousemove = helpor_net;
if (navigator.appName == "Netscape") {
}
else
{
document.write('<div ID="OuterDiv">')
document.write('<img ID="iit" src="'+image+'" STYLE="position:absolute;TOP:20pt;LEFT:20pt;Z-INDEX:20;visibility:hidden;">')
document.write('</div>')
}
</script>??
15、飄動的字符跟鼠標
??說明 在鼠標后面跟著一串飄動的字符??
??代碼
<style type="text/css">
.spanstyle {
COLOR: #00cccc; FONT-FAMILY: 宋體; FONT-SIZE: 10pt; POSITION: absolute; TOP: -50px; VISIBILITY: visible
}
</style>
<script>
var x,y
var step=18
var flag=0
var message="★歡迎你的光臨!"
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]=-200
}
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 www_helpor_net() {
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("www_helpor_net()",30)
}
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;
www_helpor_net();
// -->
</script>
16、數(shù)字時鐘
??說明 數(shù)字化的時鐘
??代碼
<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"+minutes
if(seconds<=9)
seconds="0"+seconds
myclock="現(xiàn)在時刻:<font size='5' face='Arial black'>"+hours+":"+minutes+":"+seconds+"</font>"
if(document.layers){document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}else if(document.all)
liveclock.innerHTML=myclock
setTimeout("www_helpor_net()",1000)
}
www_helpor_net();
//-->
</SCRIPT>
17、六種風格時間
??說明: 六種風格時間顯示,一定有你喜歡的!
??效果: 風格一: 星期二,6月1日,2004年
??風格二: 7:56:28上午
??風格三: 星期二,6月1日,2004年 7:56:28上午
??風格四: 6/1/04
??風格五: 7:56:28
??風格六: Tue Jun 1 07:56:28 UTC+0800 2004
??代碼:
<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>
18、顯示停留的時間
??說明: 顯示他人在頁面停留的時間,而且可以作出提醒??
??代碼:
您在本站逗留了<input type="text" name="helpor_net" size="15" style="border: 0 ">
<SCRIPT language="javascript">
<!--
var sec=0;
var min=0;
var hou=0;
flag=0;
idt=window.setTimeout("www_helpor_net();",1000);
function www_helpor_net()
{
sec++;
if(sec==60){sec=0;min+=1;}
if(min==60){min=0;hou+=1;}
if((min>0)&&(flag==0))
{
window.alert("您剛剛來了1分鐘!可別急著走開,還有好多好東東等著您呢!--站長");
flag=1;
}
helpor_net.value=hou+"小時"+min+"分"+sec+"秒";
idt=window.setTimeout("www_helpor_net();",1000);
}
//-->
</SCRIPT>
19、有影子的數(shù)字時鐘
??說明: 這個時鐘是有影子的,而且還在不停地走著呢??
??代碼:
<div id="bgclockshade" style="position:absolute;visibility:visible;font-family:'Arial black';color:#cccccc;font-size:20px;top:50px;left:173px"></div>
<div id="bgclocknoshade" style="position:absolute;visibility:visible;font-family:'Arial black';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+":"+seconds
if(document.all) {
bgclocknoshade.innerHTML=thistime
bgclockshade.innerHTML=thistime
}
if(document.layers) {
document.bgclockshade.document.write('<div id="bgclockshade" style="position:absolute;visibility:visible;font-family:Verdana;color:FFAAAAA;font-size:20px;top:10px;left:152px">'+thistime+'</div>')
document.bgclocknoshade.document.write('<div id="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>
20、全中文日期顯示
??說明: 年月日都是用全中文顯示
??代碼:
<script language="JavaScript">
<!--
function number(index1){
var numberstring="一二三四五六七八九十";
if(index1 ==0) {document.write("十")}
if(index1 < 10){
document.write(numberstring.substring(0+(index1-1),index1))}
else if(index1 < 20 ){
document.write("十"+numberstring.substring(0+(index1-11),(index1-10)))}
else if(index1 < 30 ){
document.write("二十"+numberstring.substring(0+(index1-21),(index1-20)))}
else{
document.write("三十"+numberstring.substring(0+(index1-31),(index1-30)))}
}
var today1 = new Date()
var month = today1.getMonth()+1
var date = today1.getDate()
var day = today1.getDay()
document.write("公元二零零三年")
number(month)
document.write("月")
number(date)
document.write("日")
//-->
</script>
21、打字效果
??說明: 文字在狀態(tài)欄上從左往右一個一個地顯示,就象你打出的字一樣??
??代碼: <script language="JavaScript">
var msg = "歡迎光臨,請多提意見。謝謝! " ;
var interval = 120
var spacelen = 120;
var space10=" ";
var seq=0;
function Helpor_net() {
len = msg.length;
window.status = msg.substring(0, seq+1);
seq++;
if ( seq >= len ) {
seq = 0;
window.status = '';
window.setTimeout("Helpor_net();", interval );
}
else
window.setTimeout("Helpor_net();", interval );
}
Helpor_net();
</script>
22、文字從左往右移動
??說明: 文字在狀態(tài)欄上從右往左顯示,而且是循環(huán)的??
??代碼:
<script>
<!--
function Helpor_net(seed)
{ var m1 = "歡迎來到網(wǎng)頁特效世界,請多提意見。謝謝! !" ;
var m2 = "" ;
var msg=m1+m2;
var out = " ";
var c = 1;
var speed = 120;
if (seed > 100)
{ seed-=2;
var cmd="Helpor_net(" + seed + ")";
timerTwo=window.setTimeout(cmd,speed);}
else if (seed <= 100 && seed > 0)
{ for (c=0 ; c < seed ; c++)
{ out+=" ";}
out+=msg; seed-=2;
var cmd="Helpor_net(" + seed + ")";
window.status=out;
timerTwo=window.setTimeout(cmd,speed); }
else if (seed <= 0)
{ if (-seed < msg.length)
{
out+=msg.substring(-seed,msg.length);
seed-=2;
var cmd="Helpor_net(" + seed + ")";
window.status=out;
timerTwo=window.setTimeout(cmd,speed);}
else { window.status=" ";
timerTwo=window.setTimeout("Helpor_net(100)",speed);
}
}
}
Helpor_net(100);
-->
</script>
23、圖像自動變化
??說明: 把一張圖片變形扭曲成各種不同的長寬,非常好玩??
??代碼:
<img src="http://code.helpor.net/picture/swimming.gif" name="u" border="1" alt="很好玩的">
<script language="JavaScript">
var b = 1;
var c = true;
function www_helpor_net(){
if(document.all);
if(c == true) {
b++;
}
if(b==100) {
b--;
c = false
}
if(b==10) {
b++;
c = true;
}
if(c == false) {
b--;
}
u.width=150 + b;
u.height=125 - b;
setTimeout("www_helpor_net()",50);
}
www_helpor_net();
</script>
24、漫天飛雪
??說明: 漫天飛雪
??代碼:
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
var no = 12;
var speed = 10;
var heart = "http://code.helpor.net/picture/snow.gif";
var flag;
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 800, doc_height = 600;
if (ns4up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx = new Array();
xp = new Array();
yp = new Array();
amx = new Array();
amy = new Array();
stx = new Array();
sty = new Array();
flag = new Array();
for (i = 0; i < no; ++ i) {
dx[i] = 0; // set coordinate variables
xp[i] = Math.random()*(doc_width-30)+10;
yp[i] = Math.random()*doc_height;
amy[i] = 12+ Math.random()*20;
amx[i] = 10+ Math.random()*40;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
flag[i] = (Math.random()>0.5)?1:0;
if (ns4up) { // set layers
if (i == 0) {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");
document.write("top=\"15\" visibility=\"show\"><img src=\"");
document.write(heart+ "\" border=\"0\"></layer>");
} else {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");
document.write("top=\"15\" visibility=\"show\"><img src=\"");
document.write(heart+ "\" border=\"0\"></layer>");
}
} else
if (ie4up) {
if (i == 0) {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");
document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");
document.write(heart+ "\" border=\"0\"></div>");
} else {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");
document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");
document.write(heart+ "\" border=\"0\"></div>");
}
}
}
function helpor_net() {
for (i = 0; i < no; ++ i) {
if (yp[i] > doc_height-50) {
xp[i] = 10+ Math.random()*(doc_width-amx[i]-30);
yp[i] = 0;
flag[i]=(Math.random()<0.5)?1:0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
if (flag[i])
dx[i] += stx[i];
else
dx[i] -= stx[i];
if (Math.abs(dx[i]) > Math.PI) {
yp[i]+=Math.abs(amy[i]*dx[i]);
xp[i]+=amx[i]*dx[i];
dx[i]=0;
flag[i]=!flag[i];
}
document.layers["dot"+i].top = yp[i] + amy[i]*(Math.abs(Math.sin(dx[i])+dx[i]));
document.layers["dot"+i].left = xp[i] + amx[i]*dx[i];
}
setTimeout("helpor_net()", speed);
}
function www_helpor_net() {
for (i = 0; i < no; ++ i) {
if (yp[i] > doc_height-50) {
xp[i] = 10+ Math.random()*(doc_width-amx[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
flag[i]=(Math.random()<0.5)?1:0;
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
if (flag[i])
dx[i] += stx[i];
else
dx[i] -= stx[i];
if (Math.abs(dx[i]) > Math.PI) {
yp[i]+=Math.abs(amy[i]*dx[i]);
xp[i]+=amx[i]*dx[i];
dx[i]=0;
flag[i]=!flag[i];
}
document.all["dot"+i].style.pixelTop = yp[i] + amy[i]*(Math.abs(Math.sin(dx[i])+dx[i]));
document.all["dot"+i].style.pixelLeft = xp[i] + amx[i]*dx[i];
}
setTimeout("www_helpor_net()", speed);
}
if (ns4up) {
helpor_net();
} else if (ie4up) {
www_helpor_net();
}
//-->
</script>
25、圖片漸漸顯隱
??說明: 圖片漸漸顯隱
??代碼: <img src="http://code.helpor.net/picture/swimming.gif" name="u" border="1" style="filter:alpha(opacity=0)">
<script language="JavaScript">
var b = 1;
var c = true;
function helpor_net(){
if(document.all);
if(c == true) {
b++;
}
if(b==100) {
b--;
c = false
}
if(b==10) {
b++;
c = true;
}
if(c == false) {
b--;
}
u.filters.alpha.opacity=0 + b;
setTimeout("helpor_net()",50);
}
helpor_net();
</script>
26、圖片漸漸顯示
??說明: 圖片漸漸顯示
??代碼:
<img src="http://code.helpor.net/picture/swimming.gif" border="1" id="helpor_net" style="visibility:hidden; FILTER:revealTrans(Duration=4.0, Transition=23);">
<SCRIPT FOR="window" EVENT="onLoad" LANGUAGE="vbscript">
helpor_net.filters.item(0).apply()
helpor_net.filters.item(0).transition = 12
helpor_net.Style.visibility = ""
helpor_net.filters(0).play(2.0)
</SCRIPT>
27、自由移動的圖片??
??說明: 自由移動的圖片
??效果: 看到了嗎?
??代碼:
<div id="helpor_net" style="position:absolute; visibility:visible; left:0px; top:0px; z-index:-1">
<img src="http://code.helpor.net/picture/swimming.gif" border="0">
</div>
<SCRIPT LANGUAGE="JavaScript">
<!--
var isNS = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4));
var _all = '';
var _style = '';
var wwidth, wheight;
var ydir = '++';
var xdir = '++';
var id1, id2, id3;
var x = 1;
var y = 1;
var x1, y1;
if(!isNS) {
_all='all.';
_style='.style';
}
function www_helpor_net() {
clearTimeout(id1);
clearTimeout(id2);
clearTimeout(id3);
if (isNS) {
wwidth = window.innerWidth - 55;
wheight = window.innerHeight - 50;
} else {
wwidth = document.body.clientWidth - 55;
wheight = document.body.clientHeight - 50;
}
id3 = setTimeout('randomdir()', 20000);
animate();
}
function randomdir() {
if (Math.floor(Math.random()*2)) {
(Math.floor(Math.random()*2)) ? xdir='--': xdir='++';
} else {
(Math.floor(Math.random()*2)) ? ydir='--': ydir='++';
}
id2 = setTimeout('randomdir()', 20000);
}
function animate() {
eval('x'+xdir);
eval('y'+ydir);
if (isNS) {
helpor_net.moveTo((x+pageXOffset),(y+pageYOffset))
} else {
helpor_net.pixelLeft = x+document.body.scrollLeft;
helpor_net.pixelTop = y+document.body.scrollTop;
}
if (isNS) {
if (helpor_net.top <= 5+pageYOffset) ydir = '++';
if (helpor_net.top >= wheight+pageYOffset) ydir = '--';
if (helpor_net.left >= wwidth+pageXOffset) xdir = '--';
if (helpor_net.left <= 5+pageXOffset) xdir = '++';
} else {
if (helpor_net.pixelTop <= 5+document.body.scrollTop) ydir = '++';
if (helpor_net.pixelTop >= wheight+document.body.scrollTop) ydir = '--';
if (helpor_net.pixelLeft >= wwidth+document.body.scrollLeft) xdir = '--';
if (helpor_net.pixelLeft <= 5+document.body.scrollLeft) xdir = '++';
}
id1 = setTimeout('animate()', 30);
}
var helpor_net=eval('document.'+_all+'helpor_net'+_style);
// -->
</script>
再把<body>改為:
<body OnLoad="www_helpor_net()" OnResize="www_helpor_net()">
28、隨鼠標觸動而變化
??說明: 鼠標接觸或者離開圖片時,圖片大小會相應變化??
??代碼:
<span id="s1" style = "width : 150"><a href="http://www.helpor.net" target="_blank" οnmοuseοver="www_helpor_net.style.width='200';" οnmοuseοut="www_helpor_net.style.width= '150';"><Img src="http://code.helpor.net/picture/swimming.gif" id="www_helpor_net"></a></span>
29、javascript的容錯腳本
??說明: javascript的容錯腳本,有了它,你的頁面就不會出現(xiàn)錯誤提示了。??
??代碼:
<SCRIPT LANGUAGE="JavaScript">
<!--
function Helpor_net() {
return true;
}
window.onerror = Helpor_net();
// -->
</SCRIPT>
轉(zhuǎn)載于:https://www.cnblogs.com/MaxIE/archive/2006/05/17/402904.html
總結(jié)
以上是生活随笔為你收集整理的站长常用广告代码的表达大全的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 网络搜索,抵制日货的新方法
- 下一篇: 十招赢得老板的心