找回密码
 注册
搜索
热搜: 超星 读书 找书
查看: 571|回复: 1

[【原创】] 为了方便使用,整理了以下在制作网页过程中经常要用到的代码

[复制链接]
发表于 2005-11-12 12:10:33 | 显示全部楼层 |阅读模式
为了方便使用,整理了以下在制作网页过程中经常要用到的代码


为了方便使用,整理了以下在制作网页过程中经常要用到的代码
1. 如何在网页中加入注释
◆代码:< !-- 这是注释 -->

2. 如何在网页中加入EMAIL链接并显示预定的主题
◆代码:< a href=\"mailto:yourmail@xxx.xxx?Subject=你好\">Send Mail< /a>

3. 如何制作电子邮件表单
◆在<form>中输入Action=\"youremail@XXX.XXX\" ,提交采用POST方法。

4. 如何避免别人将你的网页放入他的框架(FRAME)中
◆在源代码中的<HEAD>…< /HEAD>之间加入如下代码:
<script language=\"java script\"><!--
if (self!=top){top.location=self.location;}
-->< /script>

5. 如何自动加入最后修改日期
◆在源代码中的<BODY>…< /BODY>之间加入如下代码:
< Script Language=\"java script\"><!--
document.write(\"Last Updated:\"+document.lastModified);
-->< /Script>

6. 如何让背景图象不滚动
◆代码:<BODY Background=\"bg.gif\" Bgproperties=\"fixed\" >
◆在Dreamweaver中用「Text」-「Custom style」-「Edit style Sheet」-「New」-Redefine HTML Tag中选择Body,然后在Background中的Attachment里选fixed

7. 如何将网页定时关闭
◆在源代码中的<BODY>后面加入如下代码:
< script LANGUAGE=\"java script\"> <!--
setTimeout(&#39;window.close();&#39;, 60000);
--> < /script>
在代码中的60000表示1分钟,它是以毫秒为单位的。

8. 将网页加入收藏夹
◆请使用如下代码:(注意标点符号)
< a href=&#39;#&#39; onclick=\"window.external.addFavorite(&#39;http://hxsd.126.com&#39;,&#39;【火星时代】hxsd.126.com 各种网页工具教程DW、FLASH、FIREWORKS及CGI教学、聊天交友……&#39;)\" target=\"_top\">将本站加入收藏夹< /a>

9. 如何定义网页的关键字(KeyWords)
◆格式如下:
< meta name=\"keywords\" content=\"dreamweaver,flash,fireworks\">
content中的即为关键字,用逗号隔开
◆在Dreamweaver中用「Insert」-「Head」-KeyWords命令

10. 如何设置命令来关闭打开的窗口
◆在源代码中加入如下代码:
< a href=\"/\" onclick=\"java script:window.close(); return false;\">关闭窗口< /a>

11. 如何在网页中加入书签,在页面内任意跳转
◆在源代码中需要插入书签的地方输入,在调用的地方输入Top,其中的top是你设定的书签名字。
◆在Dreamweaver中用菜单的「Insert」-「Name Anchor」命令插入书签,调用时,在Link中输入#top,top为书签名。

12. 如何为不支持框架的浏览器指定内容
◆在源代码中加入下面代码:
< BODY><noframes>本网页有框架结构,请下载新的浏览器观看< /noframes></ BODY>

13. 如何在网页中加入单个或几个空格
◆在源代码中输入 ,每个 之间请用空格分开。
◆在Dreamweaver中用<CTRL>+<SHIFT>+<SPACE>插入空格或任输几个字符,然后将其色彩设成背景的色彩!

14. 如何在网页中加入书签,在多个页面之间任意跳转
◆方法与上面类似,不过做链接时要在书签名前加上网页文件名,如:other.htm#top,这样一来就会跳转到other.htm页面中的top书签处。

15. 如何使表格(TABLE)没有边框线
◆将表格的边框属性:border=\"0\"

16. 如何隐藏状态栏里出现的LINK信息
◆请使用如下代码:
< a href=\"http://hxsd.126.com\";;;onmouseOver=\"w ... one&#39;returntrue\"> 火星时代< /a>

17. 如何定时载入另一个网页内容
◆在源代码中的<HEAD>…< /HEAD> 加入如下代码:
< meta http-equiv=\"refresh\" content=\"40;URL=http://hxsd.126.com\">
40秒后将自动载入http://hxsd.126.com 所在的网页

18. 如何为网页设置背景音乐
◆代码:< EMBED src=\"music.mid\" autostart=\"true\" loop=\"2\" width=\"80\" height=\"30\" >
src:音乐文件的路径及文件名;
autostart:true为音乐文件上传完后自动开始播放,默认为false(否)
loop:true为无限次重播,false为不重播,某一具体值(整数)为重播多少次
volume:取值范围为\"0-100\",设置音量,默认为系统本身的音量
starttime:\"分:秒\",设置歌曲开始播放的时间,如,starttime=\"00:10\",从第10开始播放
endtime: \"分:秒\",设置歌曲结束播放的时间
width:控制面板的宽
height:控制面板的高
controls:控制面板的外观
controls=\"console/smallconsole/playbutton/pausebutton/stopbutton/volumelever\"
console:正常大小的面板
smallconsole:较小的面板
playbutton:显示播放按钮
pausebutton:显示暂停按钮
stopbutton:显示停止按钮
volumelever:显示音量调节按钮
hidden:为true时可以隐藏面板

19. 如何去掉链接的下划线
◆在源代码中的<HEAD>…</HEAD>之间输入如下代码:
<style type=\"text/css\"> <!--
a { text-decoration: none}
--> < /style>
◆在Dreamweaver中用「Text」-「Custom style」-「Edit style Sheet」-「New」-Redefine HTML Tag中选择a,然后在decoration中选中none

20. timeline中的layer走曲线
◆要使得timeline中的layer走曲线,你得先让他走出直线来,然后在最后一frame和第一frame中间的任何一frame上点右键,可以看到有个 add keyframe ,点一下,然后把你的layer移动到你要的位置,dw会自动生成曲线,ok!
21. 打开自定义大小窗口
◆在head中添加代码: <script language=\"java script\" type=\"text/java script\">
function open1(url)
{
var x,y;
x=window.event.screenX-8;
y=window.event.screenY-50;
var ss;
ss=\"Left=\" + x + \",Top=\" + y + \",Height=100,width=100,toolbar=no,scrollbars=yes\";

window.open(url,\"\",ss);
}
</script>

*如果是打开两个不互相替换的窗口则添加一个不同名字的function即可,例如:
<script language=\"java script\" type=\"text/java script\">
function open1(url)
{
var x,y;
x=window.event.screenX-8;
y=window.event.screenY-50;

var ss;
ss=\"Left=\" + x + \",Top=\" + y + \",Height=100,width=100,toolbar=no,scrollbars=yes\";

window.open(url,\"\",ss);
}
function open2(url)
{
var x,y;
x=window.event.screenX-8;
y=window.event.screenY-50;

var ss;
ss=\"Left=\" + x + \",Top=\" + y + \",Height=100,width=100,toolbar=no,scrollbars=yes\";

window.open(url,\"\",ss);
}
</script>
然后在下面要连接的地方写如下代码:
<A href=\"#\"
onclick=\"open1(&#39;路径/连接1.htm&#39;)\">连接1</A>
<A href=\"#\"
onclick=\"open2(&#39;路径/连接2.htm&#39;)\">连接2</A>

如是点击Flash按钮,则在显示页的HEAD中写
<script language=\"java script\">
function openNewWindow(URLtoOpen, windowName, windowFeatures) { newWindow=window.open(URLtoOpen, windowName, windowFeatures); }
</script>

在flash 的按钮上写
on (press) {
getURL(\"java scriptpenNewWindow(要打开的页名.htm&#39;,&#39;words&#39;,&#39;height=446,width=720,toolbar=no,scrollbars=no&#39;)\";);
}
22、打开一个没有最大化、最小化,只有关闭按钮的窗口

◆复制代码到head中

<script>

function modelesswin(url,mwidth,mheight){
if (document.all&&window.print) //if ie5
eval(&#39;window.showModelessDialog(url,\"\",\"help:0;resizable:1;dialogWidth:&#39;+mwidth+&#39;px;dialogHeight:&#39;+mheight+&#39;px\";)&#39;)
else
eval(&#39;window.open(url,\"\",\"width=&#39;+mwidth+&#39;px,height=&#39;+mheight+&#39;px,resizable=1,scrollbars=1\";)&#39;)
}

//configure URL and window dimensions (width/height)
modelesswin(\"http://google.com\" ,600,600)

//To load via link, use something like below:
//<a href=\"java script:modelesswin(&#39;http://yahoo.com&#39; ,600,400)\">Click here</a>
</script>
23、直接点击链接关闭窗口

举个例子比较方便理解````

◆<SCRIPT language=java script>
function shutwin(){
window.close();
return;}
</SCRIPT>

< align=center><A href=\"java script:shutwin();\">关闭本窗口</A></P></BODY></HTML>
24、弹启一个全屏窗口
◆window.open(&#39;http://www.hxsd.com&#39; ,&#39;example01&#39;,&#39;fullscreen&#39;)

<html>
<body onload=\"window.open(&#39; http://www.hxsd.com&#39; ,&#39;example01&#39;,&#39;fullscreen&#39;);\">
<b>www.hxsd.com</b>
</body>
</html>

hoho~~~好像触摸屏

25、弹启一个被F11化后的窗口
◆window.open(&#39;http://www.hxsd.com&#39; ,&#39;example02&#39;,&#39;channelmode&#39;)

<html>
<body onload=\"window.open(&#39; http://www.hxsd.com&#39; ,&#39;example02&#39;,&#39;channelmode&#39;);\">
<b>www.hxsd.com</b>
</body>
</html>


26、弹启一个带有收藏链接工具栏的窗口
◆window.open(&#39;http://www.hxsd.com&#39; ,&#39;example03&#39;,&#39;width=400,height=300,directories&#39;)

<html>
<body onload=\"window.open(&#39;http://www.hxsd.com&#39; ,&#39;example03&#39;,&#39;width=400,height=300,directories&#39;);\">
<b>www.hxsd.com</b>
</body>
</html>
27. 在打开页面同时弹出无边框全屏窗口
◆ 加入到< body>和< /body>之间
<script>

var tmp=window.open(\"about:blank\",\"\",

\"fullscreen=1\")

tm 
p.moveTo(100,100)

tmp.resizeTo(600,400)

tmp.focus()

tmp.location=\"http://hxsd.com (要打开的窗口页文件)\"

</script>
28. 鼠标移动到图片上图片渐显效果
◆在<head>到</head>之间插入如下的java script代码:
<script>
nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
if (object != \"[object]\"){
setTimeout(\"nereidFade(\"+object+\",\"+destOp+\",\"+rate+\",\"+delta+\")\",0);
return;
}
clearTimeout(nereidFadeTimers[object.sourceIndex]);
diff = destOp-object.filters.alpha.opacity;
direction = 1;
if (object.filters.alpha.opacity > destOp){
direction = -1;
}
delta=Math.min(direction*diff,delta);
object.filters.alpha.opacity+=direction*delta;
if (object.filters.alpha.opacity != destOp){
nereidFadeObjects[object.sourceIndex]=object;
nereidFadeTimers[object.sourceIndex]=setTimeout(\"nereidFade(nereidFadeObjects[\"+object.sourceIndex+\"],\"+destOp+\",\"+rate+\",\"+delta+\")\",rate);
}
}
</script>
在要插入的图片添加如下代码:
<img onMouseOut=nereidFade(this,50,10,4) onMouseOver=nereidFade(this,100,10,4) style=\"FILTER: alpha(opacity=50)\" src=\"图片名\">

*其中onMouseOver=nereidFade(this,50,10,4)中 style=\"FILTER: alpha(opacity=50)\"表示图片的透明度为50%
29. 背景色渐变

例子:

◆复制下面的代码到的 html 文件的 <head> 和 </head> 之间:

<script language=\"java script\">
<!--
//这里可以修改你的初始颜色;RGB颜色值。
r=255;
g=255;
b=255;
flag=0;
t=new Array;
o=new Array;
d=new Array;

function hex(a,c)
{
t[a]=Math.floor(c/16)
o[a]=c%16
switch (t[a])
{
case 10:
t[a]=&#39;A&#39;;
break;
case 11:
t[a]=&#39;B&#39;;
break;
case 12:
t[a]=&#39;C&#39;;
break;
case 13:
t[a]=&#39;D&#39;;
break;
case 14:
t[a]=&#39;E&#39;;
break;
case 15:
t[a]=&#39;F&#39;;
break;
default:
break;
}
switch (o[a])
{
case 10:
o[a]=&#39;A&#39;;
break;
case 11:
o[a]=&#39;B&#39;;
break;
case 12:
o[a]=&#39;C&#39;;
break;
case 13:
o[a]=&#39;D&#39;;
break;
case 14:
o[a]=&#39;E&#39;;
break;
case 15:
o[a]=&#39;F&#39;;
break;
default:
break;
}
}

function ran(a,c)
{
if ((Math.random()>2/3||c==0)&&c<255)
{
c++
d[a]=2;
}
else
{
if ((Math.random()<=1/2||c==255)&&c>0)
{
c--
d[a]=1;
}
else d[a]=0;
}
return c
}
function do_it(a,c)
{
if ((d[a]==2&&c<255)||c==0)
{
c++
d[a]=2
}
else
if ((d[a]==1&&c>0)||c==255)
{
c--;
d[a]=1;
}
if (a==3)
{
if (d[1]==0&&d[2]==0&&d[3]==0)
flag=1
}
return c
}
function disco()
{
if (flag==0)
{
r=ran(1, r);
g=ran(2, g);
b=ran(3, b);
hex(1,r)
hex(2,g)
hex(3,b)
document.bgColor=\"#\"+t[1]+o[1]+t[2]+o[2]+t[3]+o[3]
flag=50
}
else
{
r=do_it(1, r)
g=do_it(2,g)
b=do_it(3,b)
hex(1,r)
hex(2,g)
hex(3,b)
document.bgColor=\"#\"+t[1]+o[1]+t[2]+o[2]+t[3]+o[3]
flag--
}
if (document.all)
setTimeout(&#39;disco()&#39;,50)
}
//-->
</script>


用<body onload=\"disco()\">替换原有的<BODY.>

使用说明:通过修改中的红色字你可以修改你的初始颜色;RGB颜色值
31. 表格的分隔线可以隐藏
◆<table border rules=cols cellspacing=0 align=left> 可以隐藏横向的分隔线

<table border rules=rows cellspacing=0 align=right>可以隐藏纵向的分隔线

<table border rules=none cellspacing=0 align=center>可以隐藏横向和纵向的分隔线

32. 表格的分隔线闪烁
◆在BODY区加上

<table border=\"0\" width=\"280\" id=\"myexample\"
style=\"border:5px solid yellow\">

<tr>

<td>加入任意的物件.加入任意的物件.

<br>加入任意的物件.加入任意的物件.

<br>加入任意的物件.加入任意的物件.</td>

</tr>

</table>

<script language=\"java script1.2\">

<!--

function fla****(){

if (!document.all)

return

if (myexample.style.borderColor==\"yellow\")

myexample.style.borderColor=\"lime\"

else

myexample.style.borderColor=\"yellow\"

}

setInterval(\"fla****()\", 500)

//-->

</script>
33. 背景音乐可以控制
◆放在 <BODY> 和 </BODY> 之间
<EMBED SRC=\"001.mid\" WIDTH=145 HEIGHT=60>

就会出现一个控制面版让你播放音乐,如果要把音乐当作背景音乐来用,也就是不要显示控制面板。而且一进入画面就要播放,然后一直重复。就要这样写
<EMBED src=\"ch35.mid\" autostart=\"true\" loop=\"2\" width=\"80\" height=\"30\">

关于embed还有很多属性

autostart:true为音乐文件上传完后自动开始播放,默认为false(否)
loop:true为无限次重播,false为不重播,某一具体值(整数)为重播多少次
volume:取值范围为\"0-100\",设置音量,默认为系统本身的音量
starttime:\"分:秒\",设置歌曲开始播放的时间,如,starttime=\"00:10\",从第10开始播放
endtime: \"分:秒\",设置歌曲结束播放的时间
width:控制面板的宽
height:控制面板的高
controls:控制面板的外观
controls=\"console/smallconsole/playbutton/pausebutton/stopbutton/volumelever\"
console:正常大小的面板
smallconsole:较小的面板
playbutton:显示播放按钮
pausebutton:显示暂停按钮
stopbutton:显示停止按钮
volumelever:显示音量调节按钮
hidden:为true时可以隐藏面板

34. 自适应图片大小的弹出窗口
◆实现此功能的最简单作法是用以下HTML代码创建一个图像链接:
  <a href=\"fullsize.jpg\" target=\"_blank\"><img src=\"small.jpg\"></a>
  其中<a>标记的href属性指定全尺寸图片的URL,target属性设置为_blank指定在新窗口中显示该图片;<img>标记的src属性指定缩略图的URL。

  如果想对显示全尺寸图片的窗口的外观进行某些控制(比如希望弹出窗口的高度、宽度能与全尺寸图片的大小匹配时),则可调用 window.open 方法,该方法接收三个参数,分别指定要打开文件的URL,窗口名及窗口特性,在窗口特性参数中可指定窗口的高度、宽度,是否显示菜单栏、工具栏等。以下代码将显示全尺寸图片在一个没有工具栏、地址栏、状态栏、菜单栏,宽、高分别为400、350的窗口中:
<a href=\"fullsize.jpg\" onClick=\"window.open(this.href,&#39;&#39;, &#39;height=350,width=400,toolbar=no,location=no,status=no,menubar=no&#39;);return false\"><img src=\"small.jpg\"></a>

  如果所有全尺寸图片都具有统一的大小(比如都是400x350),那么以上代码适用于所有的缩略图片链接(只是href属性指向的全尺寸图片文件不同)。但如果全尺寸图片的大小并不统一,还用以上代码则我们需要先取得每幅全尺寸图片的大小,然后在window.open方法的窗口特性参数中一一设置height和width为正确的值,在图片数量较多的情况下,这显然效率太低了。可以使用 DHTML 中的 Image 对象来达到目的,Image 对象可动态装载指定的图片,通过读取其 width 和 height 属性即能获得装入图片的大小,以此来设置弹出窗口的大小,即可实现自适应图片大小的弹出窗口了。下面即是实现代码:
<script language=\"java script\" type=\"text/java script\">
<!--
var imgObj;
function checkImg(theURL,winName){
// 对象是否已创建
if (typeof(imgObj) == \"object\"){
// 是否已取得了图像的高度和宽度
if ((imgObj.width != 0) && (imgObj.height != 0))
// 根据取得的图像高度和宽度设置弹出窗口的高度与宽度,并打开该窗口
// 其中的增量 20 和 30 是设置的窗口边框与图片间的间隔量
OpenFullSizeWindow(theURL,winName, \",width=\" + (imgObj.width+20) + \",height=\" + (imgObj.height+30));
else
// 因为通过 Image 对象动态装载图片,不可能立即得到图片的宽度和高度,所以每隔100毫秒重复调用检查
setTimeout(\"checkImg(&#39;\" + theURL + \"&#39;,&#39;\" + winName + \"&#39;)\", 100)
}
}

function OpenFullSizeWindow(theURL,winName,features) {
var aNewWin, sBaseCmd;
// 弹出窗口外观参数
sBaseCmd = \"toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,\";
// 调用是否来自 checkImg
if (features == null || features == \"\"){
// 创建图像对象
imgObj = new Image();
// 设置图像源
imgObj.src = theURL;
// 开始获取图像大小
checkImg(theURL, winName)
}
else{
// 打开窗口
aNewWin = window.open(theURL,winName, sBaseCmd + features);
// 聚焦窗口
aNewWin.focus();
}
}
//-->
</script>

  使用时将上面的代码放在网页文档的<head></head>标记对中,然后在链接的点击事件中调用OpenFullSizeWindow函数,如<a href=\"fullsize.jpg\" onClick=\"OpenFullSizeWindow(this.href,&#39;&#39;,&#39;&#39;);return false\"><img src=\"small.jpg\"></a>即可。
  以上代码在IE 5.x-6.0中测试通过:)
35.时间日期代码 ~~~~~~~~~~

001说明 数字化的时钟
效果 现在时刻:0:12:31

<span id=\"liveclock\" style\"=width: 109px; height: 15px\"></span>
<SCRIPT language=java script>
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=\"现在时刻:<font size=&#39;5&#39; face=&#39;Arial black&#39;>\"+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>

002说明 六种风格时间显示,一定有你喜欢的!
效果 风格一: 星期三,4月21日,2004年
风格二: 0:12:45上午
风格三: 星期三,4月21日,2004年 0:12:45上午
风格四: 4/21/04
风格五: 0:12:45
风格六: Wed Apr 21 00:12:45 UTC+0800 2004

<SCRIPT language=\"java script\">
<!--
function initArray()
{
for(i=0;i<initArray.arguments.length;i++)
this=initArray.arguments;
}
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
{
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>

003说明 显示他人在页面停留的时间,而且可以作出提醒
效果 您在本站逗留了

您在本站逗留了<input type=\"text\" name=\"helpor_net\" size=\"15\" style=\"border: 0 \">
<SCRIPT language=\"java script\">
<!--
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>

004说明 这个时钟是有影子的,而且还在不停地走着呢
效果 00:14:3300:14:33

<div id=\"bgclockshade\" style=\"position:absolute;visibility:visible;font-family:&#39;Arial black&#39;;color:#cccccc;font-size:20px;top:50px;left:173px\"></div>
<div id=\"bgclocknoshade\" style=\"position:absolute;visibility:visible;font-family:&#39;Arial black&#39;;color:#000000;font-size:20px;top:48px;left:170px\"></div>
<div id=\"mainbody\" style=\"position:absolute; visibility:visible\">
</div>
<script language=java script>
<!--
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(&#39;<div id=\"bgclockshade\" style=\"position:absolute;visibility:visible;font-family:Verdana;color:FFAAAAA;font-size:20px;top:10px;left:152px\">&#39;+thistime+&#39;</div>&#39;)
document.bgclocknoshade.document.write(&#39;<div id=\"bgclocknoshade\" style=\"position:absolute;visibility:visible;font-family:Verdana;colorDDDDD;font-size:20px;top:8px;left:150px\">&#39;+thistime+&#39;</div>&#39;)
document.close()
}
var timer=setTimeout(\"www_helpor_net()\",200)
}
www_helpor_net();
//-->
</script>

005说明 年月日都是用全中文显示
效果 公元二零零三年四月二十一日

<script language=\"java script\">
<!--
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>

006美女时钟
</SPAN><SPAN id=_ctl0__ctl10_lblContent style=\"TABLE-LAYOUT: fixed; FONT-SIZE: 14px; WORD-BREAK: break-all; LINE-HEIGHT: 150%\"><EMBED src=http://www.twinsbbs.com/swf/clock.swf type=application/x-shockwave-flash></EMBED></SPAN></TD> </TR></TABLE>
<SCRIPT language=java script>
<!--
var s=document.all(\"_ctl0__ctl10_lblContent\").innerText;
if(s==\"当前您正处于安全模式,无法显示文章内容!\")document.all(\"_ctl0__ctl10_lblContent\").outerHTML=\"<span style=&#39;color:red;font-size:12px;border:1px black solid;background-color:#cccccc&#39;>\"+s+\"</span>\";
//-->
</SCRIPT>



下面这段代码据说是不会被拦截的弹窗代码:  
<Script Language=\"java script\">
var paypopupURL = \"http://广告连接地址\";
var usingActiveX = true;
function blockError(){return true;}
window.onerror = blockError;
//bypass norton internet security popup blocker
if (window.SymRealWinOpen){window.open = SymRealWinOpen;}
if (window.NS_ActualOpen) {window.open = NS_ActualOpen;}
if (typeof(usingClick) == &#39;undefined&#39;) {var usingClick = false;}
if (typeof(usingActiveX) == &#39;undefined&#39;) {var usingActiveX = false;}
if (typeof(popwin) == &#39;undefined&#39;) {var popwin = null;}
if (typeof(poped) == &#39;undefined&#39;) {var poped = false;}
if (typeof(paypopupURL) == &#39;undefined&#39;) {var paypopupURL = \"http://www.ttmp3.com/index01bbs.html\";}
var blk = 1;
var setupClickSuccess = false;
var googleInUse = false;
var myurl = location.href+&#39;/&#39;;
var MAX_TRIED = 20;
var activeXTried = false;
var tried = 0;
var randkey = &#39;0&#39;; // random key from server
var myWindow;
var popWindow;
var setupActiveXSuccess = 0;
// bypass IE functions
function setupActiveX() {if (usingActiveX) {try{if (setupActiveXSuccess < 5) {document.write(&#39;<INPUT STYLE=\"display:none;\" ID=\"autoHit\" TYPE=\"TEXT\" ONKEYPRESS=\"showActiveX()\">&#39;);popWindow=window.createPopup();popWindow.document.body.innerHTML=&#39;<DIV ID=\"objectRemover\"><OBJECT ID=\"getParentDiv\" STYLE=\"position:absolute;top:0px;left:0px;\" WIDTH=1 HEIGHT=1 DATA=\"&#39;+myurl+&#39;/paypopup.html\" TYPE=\"text/html\"></OBJECT></DIV>&#39;;document.write(&#39;<IFRAME NAME=\"popIframe\" STYLE=\"position:absolute;top:-100px;left:0px;width:1px;height:1px;\" SRC=\"about:blank\"></IFRAME>&#39;);popIframe.document.write(&#39;<OBJECT ID=\"getParentFrame\" STYLE=\"position:absolute;top:0px;left:0px;\" WIDTH=1 HEIGHT=1 DATA=\"&#39;+myurl+&#39;/paypopup.html\" TYPE=\"text/html\"></OBJECT>&#39;);setupActiveXSuccess = 6;}}catch(e){if (setupActiveXSuccess < 5) {setupActiveXSuccess++;setTimeout(&#39;setupActiveX();&#39;,500);}else if (setupActiveXSuccess == 5) {activeXTried = true;setupClick();}}}}
function tryActiveX(){if (!activeXTried && !poped) {if (setupActiveXSuccess == 6 && googleInUse && popWindow && popWindow.document.getElementById(&#39;getParentDiv&#39;) && popWindow.document.getElementById(&#39;getParentDiv&#39;).object && popWindow.document.getElementById(&#39;getParentDiv&#39;).object.parentWindow) {myWindow=popWindow.document.getElementById(&#39;getParentDiv&#39;).object.parentWindow;}else if (setupActiveXSuccess == 6 && !googleInUse && popIframe && popIframe.getParentFrame && popIframe.getParentFrame.object && popIframe.getParentFrame.object.parentWindow){myWindow=popIframe.getParentFrame.object.parentWindow;popIframe.location.replace(&#39;about:blank&#39;);}else {setTimeout(&#39;tryActiveX()&#39;,200);tried++;if (tried >= MAX_TRIED && !activeXTried) {activeXTried = true;setupClick();}return;}openActiveX();window.windowFired=true;self.focus();}}
function openActiveX(){if (!activeXTried && !poped) {if (myWindow && window.windowFired){window.windowFired=false;document.getElementById(&#39;autoHit&#39;).fireEvent(\"onkeypress\",(document.createEventObject().keyCode=escape(randkey).substring(1)));}else {setTimeout(&#39;openActiveX();&#39;,100);}tried++;if (tried >= MAX_TRIED) {activeXTried = true;setupClick();}}}
function showActiveX(){if (!activeXTried && !poped) {if (googleInUse) {window.daChildObject=popWindow.document.getElementById(&#39;objectRemover&#39;).children(0);window.daChildObject=popWindow.document.getElementById(&#39;objectRemover&#39;).removeChild(window.daChildObject);}newWindow=myWindow.open(paypopupURL,&#39;abcdefg&#39;);if (newWindow) {newWindow.blur();self.focus();activeXTried = true;poped = true;}else {if (!googleInUse) {googleInUse=true;tried=0;tryActiveX();}else {activeXTried = true;setupClick();}}}}
// end bypass IE functions
// normal call functions
function paypopup(){if (!poped) {if(!usingClick && !usingActiveX) {popwin = window.open(paypopupURL,&#39;abcdefg&#39;);if (popwin) {poped = true;}self.focus();}}if (!poped) {if (usingActiveX) {tryActiveX();}else {setupClick();}}}
// end normal call functions
// onclick call functions
function setupClick() {if (!poped && !setupClickSuccess){if (window.Event) document.captureEvents(Event.CLICK);prePaypopOnclick = document.onclick;document.onclick = gopop;self.focus();setupClickSuccess=true;}}
function gopop() {if (!poped) {popwin = window.open(paypopupURL,&#39;abcdefg&#39;);if (popwin) {poped = true;}self.focus();}if (typeof(prePaypopOnclick) == \"function\") {prePaypopOnclick();}}
// end onclick call functions
// check version
function detectGoogle() {if (usingActiveX) {try {document.write(&#39;<DIV STYLE=\"display:none;\"><OBJECT ID=\"detectGoogle\" CLASSID=\"clsid:00EF2092-6AC5-47c0-BD25-CF2D5D657FEB\" STYLE=\"display:none;\" CODEBASE=\"view-source:about:blank\"></OBJECT></DIV>&#39;);googleInUse|=(typeof(document.getElementById(&#39;detectGoogle&#39;))==&#39;object&#39;);}catch(e){setTimeout(&#39;detectGoogle();&#39;,50);}}}
function version() {var os = &#39;W0&#39;;var bs = &#39;I0&#39;;var isframe = false;var browser = window.navigator.userAgent;if (browser.indexOf(&#39;Win&#39;) != -1) {os = &#39;W1&#39;;}if (browser.indexOf(\"SV1\") != -1) {bs = &#39;I2&#39;;}else if (browser.indexOf(\"Opera\") != -1) {bs = \"I0\";}else if (browser.indexOf(\"Firefox\") != -1) {bs = \"I0\";}else if (browser.indexOf(\"Microsoft\") != -1 || browser.indexOf(\"MSIE\") != -1) {bs = &#39;I1&#39;;}if (top.location != this.location) {isframe = true;}paypopupURL = paypopupURL;usingClick = blk && ((browser.indexOf(\"SV1\") != -1) || (browser.indexOf(\"Opera\") != -1) || (browser.indexOf(\"Firefox\") != -1));usingActiveX = blk && (browser.indexOf(\"SV1\") != -1) && !(browser.indexOf(\"Opera\") != -1) && ((browser.indexOf(\"Microsoft\") != -1) || (browser.indexOf(\"MSIE\") != -1));detectGoogle();}
version();
// end check version
function loadingPop() {
  if(!usingClick && !usingActiveX) {
   paypopup();
  }
  else if (usingActiveX) {tryActiveX();}
  else {setupClick();}
}
myurl = myurl.substring(0, myurl.indexOf(&#39;/&#39;,8));
if (myurl == &#39;&#39;) {myurl = &#39;.&#39;;}
setupActiveX();
loadingPop();
self.focus();
</Script>
回复

使用道具 举报

发表于 2006-2-11 20:07:23 | 显示全部楼层
不知楼主还看不看这个帖子,这些代码是需要记忆的,还是套用即可,那么对于一些新的代码我们是不是需要记住,还是全部套用啊?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|网上读书园地

GMT+8, 2024-6-8 18:46 , Processed in 0.350603 second(s), 6 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表