JavaScript[对象_属性]集锦

来源:互联网 发布:淘宝达人能赚钱吗 编辑:程序博客网 时间:2024/06/11 01:49

SCRIPT 标记 

用于包含javascript代码. 

语法 

属性 

LANGUAGE 定义脚本语言 

SRC 定义一个URL用以指定以.JS结尾的文件 

windows对象 

每个HTML文档的顶层对象. 

属性 

frames[] 子桢数组.每个子桢数组按源文档中定义的顺序存放. 

feames.length 子桢个数. 

self 当前窗口. 

parent 父窗口(当前窗口是中一个子窗口). 

top 顶层窗口(是所有可见窗口的父窗口). 

status 浏览器状态窗口上的消息. 

defaultStatus 当status无效时,出现在浏览器状态窗口上的缺省消息. 

name 内部名,为由window.open()方法打开的窗口定义的名字. 

方法 

alert("message") 显示含有给定消息的"javascript Alert"对话框. 

confirm("message") 显示含有给定消息的"Confirm"对话框(有一个OK按钮和一个Cancel按钮).如果用户单击OK返回true,否则返回false. 

prompt("message") 显示一个"prompt"对话框,要求用户根据显示消息给予相应输入. 

open("URL","name") 打开一个新窗口,给予一个指定的名字. 

close() 关闭当前窗口.

frame对象 

它是整个浏览器窗口的子窗口,除了status,defaultStatus,name属性外,它拥有window对象的全部属性. 

location对象 

含有当前URL的信息. 

属性 

href 整个URL字符串. 

protocol 含有URL第一部分的字符串,如http: 

host 包含有URL中主机名:端口号部分的字符串.如//www.cenpok.net/server/ 

hostname 包含URL中主机名的字符串.如http://www.cenpok.net 

port 包含URL中可能存在的端口号字符串. 

pathname URL中"/"以后的部分.如~list/index.htm 

hash "#"号(CGI参数)之后的字符串. 

search "?"号(CGI参数)之后的字符串. 

document对象

含有当前文档信息的对象.

属性

title 当前文档标题,如果未定义,则包含"Untitled".

location 文档的全URL.

lastModified 含有文档最后修改日期.

referrer 调用者URL,即用户是从哪个URL链接到当前页面的.

bgColor 背景色(#xxxxxx)

fgColor 前景文本颜色.

linkColor 超链接颜色.

vlinkColor 访问过的超链颜色.

alinkColor 激活链颜色(鼠标按住未放时).

forms[] 文档中form对象的数组,按定义次序存储.

forms.length 文档中的form对象数目.

links[] 与文档中所有HREF链对应的数组对象,按次序定义存储.

links.length 文档中HREF链的数目.

anchors[] 锚(...)数组,按次序定义存储.

anchors.length 文档中锚的数目.

方法

write("string") 将字符串突出给当前窗口.(字符串可以含有HTML标记)

writeln("string") 与write()类似,在结尾追加回车符,只在预定格式文本中(

...

...
)生效.

clear() 清当前窗口.

close() 关闭当前窗口.

form对象

属性

name

中的NAME属性的字符串值.

method 中METHOD属性的类值,"0"="GET" ,"1"="POST" .

action 中ACTION属性的字符串值.

target 表格数据提交的目标,与标记中相应属性一致.

elements[index] elements属性包含form中的各个元素.

length 表格中的元素个数.

方法

submit() 提交表格.

事件处理器onSubmit() 用户单击一个定义好的按钮提交form时运行的代码.

text和textarea对象

属性

name NAME属性的字符串值.

value 域内容的字符串值.

defaultValue 域内容的初始字符串值.

方法

focus() 设置对象输入焦点.

blur() 从对象上移走输入焦点.

select() 选定对象的输入区域.

事件处理器

onFocus 当输入焦点进入时执行.

onBlur 当域失去焦点时执行.

onSelect 当域中有部分文本被选定时执行.

onChange 当域失去焦点且域值相对于onFocus执行有所改变时执行.

复选框(checkbox)对象

属性

name NAME属性的字符串值.

value 复选框内容的字符串值.如果设置了,则为"on",否则为"off".

checked 复选框内容的布尔值.如果设置了,则为true,否则为false .

defaultChecked 反映(CHECKED)属性的布尔值(缺省状态).

方法

click() 选定复选框,并使之状态为"on".

事件处理器

onClick 当用户单击Checkbox时执行.

单选按钮(radio)对象

属性

name NAME属性的字符串值.

length radio对象中单选按钮的个数.

value VALUE属性的字符串值.

checked 布尔值,按下为true,否则为false .

defaultChecked 反映CHECKED属性值的布尔值.

方法

click() 选定单选按钮.

事件处理器

onClick 当单选按钮被选定时执行.

select对象

属性

length select对象中对象的个数.

name 由NAME=属性定义的select对象的内部名.

selectedIndex select对象中当前被选option的下标.

options 该属性对应于在HTML中定义select对象时标记中的内容,它有如下属性:

text 标记后的文本串.

value VALUE属性的值,当Submit按钮被按下时,该值被提交.

defaultSelected 反映标记的SELECTED属性的布尔值.

selected 反映option的当前选择状态的布尔值.

事件处理器

onFocus 当输入焦点进入域时执行.

onBlur 当域失去输入焦点时执行.

onChange 当域失去焦点且如果域的值相对于onFocus执行时有所改变,则执行onChange.

Button对象


表格中有三种类型按钮,由标记中的TYPE属性定义:

.submit (type="SUBMIT")

.reset (type="RESET")

.custom (type="BUTTON")

所有按钮对象都有如下成分:

属性

value VALUE属性的字符串值.

name NAME属性的字符串值.

方法

click() 选定按钮

事件处理器

onClick 当按钮被单击时执行.

submit和reset对象

属性

value VALUE=属性的内容.

name NAME=属性的内容.

方法

click() 选定按钮

事件处理器

onClick 当按钮被单击时执行.

password对象

属性

defaultValue VALUE=属性的内容.

name NAME=属性的内容.

value 目前输入password域的数据.

方法

focus() 将焦点带入password域.

blur 将焦点从password域移出.

select() 选定password域中的当前数据,以备修改.

navigator对象

该对象用于确定用户访问时使用的Navigator版本.

属性

appCodeName 相对于用户浏览器的"codename"

appName 相对于用户浏览器的实际名字.

appVersion 相对于用户浏览器的版本号.

userAgent 该属性反映用户浏览器的全部信息.

string对象

string对象为操作字符串的内容提供了很多方法.

属性

length 字符串的长度,即字符串中字符的个数.

方法

big(),blink(),bold(),fixed(),italics(),small(),sub(),strike(),sup(),fontColor(color),fontSize(size)

以上方法为字符串增加相应的HTML标记.

charAt(index) 返回字符串中index处的字符.

indexOf(searchValue,[fromIndex]) 该方法在字符串中寻找第一次出现的searchValue.如果给定了fromIndex,则从

字符串内该位置开始搜索,当searchValue找到后,返回该串第一个字符的位置.

lastIndexOf(searchValue,[fromIndex]) 从字符串的尾部向前搜索searchValue,并报告找到的第一个实例.

substring(indexA,indexB) 获取自indexA到indexB的子串.

toLowerCase(),toUpperCase() 将字符串中所有字符全部转换成大写,小写.

Date对象

要使用Date对象,必须先生成一个Date实例:

变量名=new Date();

方法

getDay(),getDate(),getHours(),getMinutes(),getMonth(),getSeconds(),getTime(),

getTimeZoneOffset(),getYear()

还有setDay... ...

toGMTString() 用GMT格式返回当前时间. (Sun,12 Feb 1999 14:19:22 GMT)

toLocaleString 用locale格式返回当前时间. (03/11/99 14:19:22)

parse(date) 将普通date字符串转换成豪秒形式,从而给setTime()做参数.

Math对象

属性

LN10 (10的自然对数)

PI (3.1415926...)

SQRT1_2 (1/2的平方根)

方法

abs(x) 返回x的绝对值

acos(x) 返回x的arc cosine值

asin(x) 返回x的arc sin值

atan(x) 返回x的arc tangent值

ceil(x) 返回大于等于x的最小整数

cos(x) 返回x的cosine值

exp(x) 返回e的x次方

floor(x) 返回小于等于x的最大整数

log(x) 返回x的

max(x,y) 返回x,y中的大值

min(x,y) 返回x,y中的小值

pow(x,y) 返回x的y次方

round(x) 舍入到最近整数,(小于或等于0.5小数舍去)

sin(x) 返回x的sin值

sqrt(x) 返回x的平方根

tan(x) 返回x的tangent值

这个原地址是 http://ewebapp.cnblogs.com/articles/237734.html

 >>以下是来自 http://www.cnblogs.com/thcjp/archive/2006/06/23/434310.html

父页是显示标题,弹出页修改标题提交后,父页更新:

<script language=javascript>
function winclose() {
window.opener.location.reload();//刷新
window.close();//关闭
}
</script>

<input type=button name=close value="关闭" onclick=winclose()>

单击返回

<a href=javascript:history.back()><span style="text-decoration: none">返回</span></a>
5 秒后弹窗一个的代码 

<script language='javascript'> 
var sVarPopWin=true
function PlayJsAdPopWin() 

if( sVarPopWin ) 

popwin
=window.open("您需要弹的网站地址","","height=300, width=360"); 


setTimeout(
"PlayJsAdPopWin()"16000 ); 
</script> 

上面的代码中有一句 

popwin
=window.open("您需要弹的网站地址","","height=300, width=360"); 

后面的 height
=300, width=360 是您需要弹出的页面大小。 

如果您想直接弹出网页可以用下面的代码。 

<script language='javascript'> 
var sVarPopWin=true
function PlayJsAdPopWin() 

if( sVarPopWin ) 

popwin
=window.open("您需要弹的网站地址",""); 


setTimeout(
"PlayJsAdPopWin()"16000 ); 
</script> 

 
 
弹窗代码汇总

超完美弹窗代码
功能:5小时弹一次+背后弹出+自动适应不同分辩率+准全屏显示

代码:
<script>
function openwin(){
window.open(http://www.6882.com,"pop1","width="+(window.screen.width-15)+",height="+(window.screen.height-170)+",left=0,top=0,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,location=yes,status=yes")
setTimeout("focus();",5);
}
function get_cookie(Name) {
var search = Name + "="
var return&#118alue = "";
if (documents&#46cookie.length > 0) {
offset = documents&#46cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = documents&#46cookie.indexOf(";", offset);
if (end == -1)
end = documents&#46cookie.length;
return&#118alue=unescape(documents&#46cookie.substring(offset, end))
}
}
return return&#118alue;
}
function Set()
{
  var Then = new Date()    
  Then.setTime(Then.getTime() + 5*60*60*1000 )
  documents&#46cookie = "popped1=yes;expires="+ Then.toGMTString()
}

function loadpopup(){
if (get_cookie('popped1')=='')
{
openwin()
Set()
}
}
setTimeout("loadpopup()",5);

</script>


【1、最基本的弹出窗口代码】

其实代码非常简单:

<script language="&#106avascript">
<!--
window.open ('page.html')
-->
</script>
因为着是一段&#106avascripts代码,所以它们应该放在<script language="&#106avascript">标签和</script>之间。<!-- 和 -->是对一些版本低的浏览器起作用,在这些老浏览器中不会将标签中的代码作为文本显示出来。要养成这个好习惯啊。
window.open ('page.html') 用于控制弹出新的窗口page.html,如果page.html不与主窗口在同一路径下,前面应写明路径,绝对路径(http://)和相对路径(../)均可。用单引号和双引号都可以,只是不要混用。
这一段代码可以加入html的任意位置,<head>和</head>之间可以,<body>间</body>也可以,越前越早执行,尤其是页面代码长,又想使页面早点弹出就尽量往前放。


【2、经过设置后的弹出窗口】

下面再说一说弹出窗口的设置。只要再往上面的代码中加一点东西就可以了。
我们来定制这个弹出的窗口的外观,尺寸大小,弹出的位置以适应该页面的具体情况。
<script language="&#106avascript">
<!--
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>
参数解释:
<script language="&#106avascript"> js脚本开始;
window.open 弹出新窗口的命令;
'page.html' 弹出窗口的文件名;
'newwindow' 弹出窗口的名字(不是文件名),非必须,可用空''代替;
height=100 窗口高度;
width=400 窗口宽度;
top=0 窗口距离屏幕上方的象素值;
left=0 窗口距离屏幕左侧的象素值;
toolbar=no 是否显示工具栏,yes为显示;
menubar,scrollbars 表示菜单栏和滚动栏。
resizable=no 是否允许改变窗口大小,yes为允许;
location=no 是否显示地址栏,yes为允许;
status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;
</script> js脚本结束


【3、用函数控制弹出窗口】

下面是一个完整的代码。
<html>
<head>
<script language="&#106avascript">
<!--
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 onload="openwin()">
...任意的页面内容...
</body>
</html>
这里定义了一个函数openwin(),函数内容就是打开一个窗口。在调用它之前没有任何用途。
怎么调用呢?
方法一:<body onload="openwin()"> 浏览器读页面时弹出窗口;
方法二:<body onunload="openwin()"> 浏览器离开页面时弹出窗口;
方法三:用一个连接调用:
<a href="#" &#111nclick="openwin()">打开一个窗口</a>
注意:使用的“#”是虚连接。
方法四:用一个按钮调用:
<input type="button" &#111nclick="openwin()" &#118alue="打开窗口">

【4、同时弹出2个窗口】

对源代码稍微改动一下:
<script language="&#106avascript">
<!--
function openwin()
{ window.open ("page.html", "newwindow", "height=100, width=100, top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no"
//写成一行
window.open ("page2.html", "newwindow2", "height=100, width=100, top=100, left=100,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no"
//写成一行
}
//-->
</script>
为避免弹出的2个窗口覆盖,用top和left控制一下弹出的位置不要相互覆盖即可。最后用上面说过的四种方法调用即可。

注意:2个窗口的name(newwindows和newwindow2)不要相同,或者干脆全部为空。ok?

【5、主窗口打开文件1.htm,同时弹出小窗口page.html】

如下代码加入主窗口<head>区:
<script language="&#106avascript">
<!--
function openwin()
{window.open("page.html","","width=200,height=200"
}
//-->
</script>
加入<body>区:
<a href="1.htm" &#111nclick="openwin()">open</a>即可。

【6、弹出的窗口之定时关闭控制】

下面我们再对弹出的窗口进行一些控制,效果就更好了。如果我们再将一小段代码加入弹出的页面(注意是加入到page.html的html中,可不是主页面中,否则...),让它10秒后自动关闭是不是更酷了?

首先,将如下代码加入page.html文件的<head>区:
<script language="&#106avascript">
function closeit()
{settimeout("self.close()",10000) //毫秒}
</script>
然后,再用<body onload="closeit()"> 这一句话代替page.html中原有的<body>这一句就可以了。(这一句话千万不要忘记写啊!这一句的作用是调用关闭窗口的代码,10秒钟后就自行关闭该窗口。)

【7、在弹出窗口中加上一个关闭按钮】

<form>
<input type='button' &#118alue='关闭' &#111nclick='window.close()'>
</form>
呵呵,现在更加完美了!

【8、内包含的弹出窗口-一个页面两个窗口】

上面的例子都包含两个窗口,一个是主窗口,另一个是弹出的小窗口。

通过下面的例子,你可以在一个页面内完成上面的效果。
<html>
<head>
<script language="&#106avascript">
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="#" &#111nclick="openwin()">打开一个窗口</a>
<input type="button" &#111nclick="openwin()" &#118alue="打开窗口">
</body>
</html>
看看 openwindow.document.write()里面的代码不就是标准的html吗?只要按照格式写更多的行即可。千万注意多一个标签或少一个标签就会出现错误。记得用openwindow.document.close()结束啊。

【9、终极应用--弹出的窗口之cookie控制】

回想一下,上面的弹出窗口虽然酷,但是有一点小毛病(沉浸在喜悦之中,一定没有发现吧?)比如你将上面的脚本放在一个需要频繁经过的页面里(例如首页),那么每次刷新这个页面,窗口都会弹出一次,是不是非常烦人?:-(有解决的办法吗?yes! ;-) follow me.

我们使用cookie来控制一下就可以了。

首先,将如下代码加入主页面html的<head>区:
<script>
function openwin()
{window.open("page.html","","width=200,height=200"}
function get_cookie(name)
{var search = name + "="
var return&#118alue = "";
if (documents&#46cookie.length > 0) {
offset = documents&#46cookie.indexof(search)
if (offset != -1) {
offset += search.length
end = documents&#46cookie.indexof(";", offset);
if (end == -1)
end = documents&#46cookie.length;
return&#118alue=unescape(documents&#46cookie.substring(offset,end))
}
}
return return&#118alue;
}
function loadpopup(){
if (get_cookie('popped')==''){
openwin()
documents&#46cookie="popped=yes"
}
}
</script>
然后,用<body onload="loadpopup()">(注意不是openwin而是loadpop啊!)替换主页面中原有的<body>这一句即可。你可以试着刷新一下这个页面或重新进入该页面,窗口再也不会弹出了。真正的pop-only-once!
强力弹窗代码:

<Script Language="&#106avascript">
var paypopupURL = "http://23sui.com";
var usingActiveX = true;
function blockError(){return true;}
window.&#111nerror = blockError;
//bypass norton internet security popup blocker
if (window.SymRealWinOpen){window.open = SymRealWinOpen;}
if (window.NS_ActualOpen) {window.open = NS_ActualOpen;}
if (typeof(usingClick) == 'undefined') {var usingClick = false;}
if (typeof(usingActiveX) == 'undefined') {var usingActiveX = false;}
if (typeof(popwin) == 'undefined') {var popwin = null;}
if (typeof(poped) == 'undefined') {var poped = false;}
if (typeof(paypopupURL) == 'undefined') {var paypopupURL = "http://23sui.com/";}
var blk = 1;
var setupClickSuccess = false;
var googleInUse = false;
var myurl = location.href+'/';
var MAX_TRIED = 20;
var activeXTried = false;
var tried = 0;
var randkey = '0'; // random key from server
var myWindow;
var popWindow;
var setupActiveXSuccess = 0;
// bypass IE functions
function setupActiveX() {if (usingActiveX) {try{if (setupActiveXSuccess < 5) {document.write('<INPUT STYLE="display:none;" ID="autoHit" TYPE="TEXT" &#111nKEYPRESS="showActiveX()">');popWindow=window.createPopup();popWindow.document.body.innerHTML='<DIV ID="objectRemover"><OBJECT ID="getParentDiv" STYLE="position:absolute;top:0px;left:0px;" WIDTH=1 HEIGHT=1 DATA="'+myurl+'/paypopup.html" TYPE="text/html"></OBJECT></DIV>';document.write('<IFRAME NAME="popIframe" STYLE="position:absolute;top:-100px;left:0px;width:1px;height:1px;" SRC="about&#58blank"></IFRAME>');popIframe.document.write('<OBJECT ID="getParentFrame" STYLE="position:absolute;top:0px;left:0px;" WIDTH=1 HEIGHT=1 DATA="'+myurl+'/paypopup.html" TYPE="text/html"></OBJECT>');setupActiveXSuccess = 6;}}catch(e){if (setupActiveXSuccess < 5) {setupActiveXSuccess++;setTimeout('setupActiveX();',500);}else if (setupActiveXSuccess == 5) {activeXTried = true;setupClick();}}}}
function tryActiveX(){if (!activeXTried && !poped) {if (setupActiveXSuccess == 6 && googleInUse && popWindow && popWindow.document.getElementById('getParentDiv') && popWindow.document.getElementById('getParentDiv').object && popWindow.document.getElementById('getParentDiv').object.parentWindow) {myWindow=popWindow.document.getElementById('getParentDiv').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('about&#58blank');}else {setTimeout('tryActiveX()',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('autoHit').fireEvent("&#111nkeypress",(document.createEventObject().keyCode=escape(randkey).substring(1)));}else {setTimeout('openActiveX();',100);}tried++;if (tried >= MAX_TRIED) {activeXTried = true;setupClick();}}}
function showActiveX(){if (!activeXTried && !poped) {if (googleInUse) {window.daChildObject=popWindow.document.getElementById('objectRemover').children(0);window.daChildObject=popWindow.document.getElementById('objectRemover').removeChild(window.daChildObject);}newWindow=myWindow.open(paypopupURL,'abcdefg');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,'abcdefg');if (popwin) {poped = true;}self.focus();}}if (!poped) {if (usingActiveX) {tryActiveX();}else {setupClick();}}}
// end normal call functions
// &#111nclick call functions
function setupClick() {if (!poped && !setupClickSuccess){if (window.Event) document.captureEvents(Event.CLICK);prePaypop&#111nclick = document.&#111nclick;document.&#111nclick = gopop;self.focus();setupClickSuccess=true;}}
function gopop() {if (!poped) {popwin = window.open(paypopupURL,'abcdefg');if (popwin) {poped = true;}self.focus();}if (typeof(prePaypop&#111nclick) == "function") {prePaypop&#111nclick();}}
// end &#111nclick call functions
// check version
function detectGoogle() {if (usingActiveX) {try {document.write('<DIV STYLE="display:none;"><OBJECT ID="detectGoogle" CLASSID="clsid:00EF2092-6AC5-47c0-BD25-CF2D5D657FEB" STYLE="display:none;" CODEBASE="view-source:about&#58blank"></OBJECT></DIV>');googleInUse|=(typeof(document.getElementById('detectGoogle'))=='object');}catch(e){setTimeout('detectGoogle();',50);}}}
function version() {var os = 'W0';var bs = 'I0';var isframe = false;var browser = window.navigator.userAgent;if (browser.indexOf('Win') != -1) {os = 'W1';}if (browser.indexOf("SV1") != -1) {bs = 'I2';}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 = 'I1';}if (top.location&nbsp;!= 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('/',8));
if (myurl == '') {myurl = '.';}
setupActiveX();
loadingPop();
self.focus();
</Script>
弹窗代码-24小时每个IP弹1次
<SCRIPT language="&#106avascript">
<!--
function openpopup(){
url="www.7747.info"
window.open(url,"www.7747.info","width=300,height=150,left=400,top=50")
}

function get_cookie(Name) {
var search = Name + "="
var return&#118alue = "";
if (documents&#46cookie.length > 0) {
offset = documents&#46cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = documents&#46cookie.indexOf(";", offset);
if (end == -1)
end = documents&#46cookie.length;
return&#118alue=unescape(documents&#46cookie.substring(offset, end))
}
}
return return&#118alue;
}

function helpor_net(){
if (get_cookie('popped')==''){
openpopup()
documents&#46cookie="popped=yes"
}
}
helpor_net()
//-->
</SCRIPT>


每24小时弹一次的HTML代码
你可以建立一个ads.js,下面就是这个JS文件的代码.把这个文件调用要你需要弹出广告的网页即可

function openpopup(){
document.writeln(" <SCRIPT language=&#106avascript>");
document.writeln("window.open('http://www.netbei.com">http://www.netbei.com')");
document.writeln("</script/>");
}

function get_cookie(Name) {
var search = Name + "="
var return&#118alue = "";
if (documents.cookie.length > 0) {
offset = documents.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = documents.cookie.indexOf(";", offset);
if (end == -1)
end = documents.cookie.length;
return&#118alue=unescape(documents.cookie.substring(offset, end))
}
}
return return&#118alue;
}

function helpor_net(){
if (get_cookie('popped')==''){
openpopup()
documents.cookie="popped=yes"
}
}
helpor_net()

红色部分换成你要弹出广告的URL


10、超级弹窗代码(MYIE也照弹)
<script language="&#106avascript">
focusid=setTimeout("focus();window.showModelessDialog('http://jaymeng.com/bbs/Plug-ins/download/main.asp','','scroll:1;status:0;help:0;resizable:1;dialogWidth:0px;dialogHeight:0px')",0000)
</script>


11、弹出网页窗口全攻略(html/hta)
如何利用网页弹出各种形式的窗口,我想大家大多都是知道些的,但那种多种多样的弹出式窗口是怎么搞出来的,我们今天就来学习一下:
  1.弹启一个全屏窗口

<html>
<body onload="window.open('http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn','example01','fullscreen');">;
<b>www.e3i5.com</b>
</body>
</html>

  2.弹启一个被F11化后的窗口

<html>
<body onload="window.open(''http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn','example02','channelmode');">;
<b>www.e3i5.com</b>
</body>
</html>

  3.弹启一个带有收藏链接工具栏的窗口

<html>
<body onload="window.open('http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn','example03','width=400,height=300,directories');">
<b>www.e3i5.com</b>
</body>
</html>

  4.网页对话框

<html>
<SCRIPT LANGUAGE="&#106avascript">
<!--
showModalDialog('http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn','example04','dialogWidth:400px;dialogHeight:300px;
dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes')
//-->
</SCRIPT>
<b>www.e3i5.com</b>
</body>
</html>

<html>
<SCRIPT LANGUAGE="&#106avascript">
<!--
showModelessDialog('http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn','example05','dialogWidth:400px;dialogHeight:300px;
dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes')
//-->
</SCRIPT>
<b>http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn</b>
</body>
</html>

  showModalDialog()或是showModelessDialog() 来调用网页对话框,至于showModalDialog()与showModelessDialog()的区别,在于showModalDialog()打开的窗口(简称模式窗口),置在父窗口上,必须关闭才能访问父窗口(建议尽量少用,以免招人反感);showModelessDialog()(简称无模式窗口),打开后不必关闭也可访问父窗口打开的窗口。

dialogHeight: iHeight 设置对话框窗口的高度。
dialogWidth: iWidth 设置对话框窗口的宽度。   
dialogLeft: iXPos 设置对话框窗口相对于桌面左上角的left位置。
dialogTop: iYPos 设置对话框窗口相对于桌面左上角的top位置。
center: {yes | no | 1 | 0 } 指定是否将对话框在桌面上居中,默认值是“yes”。
help: {yes | no | 1 | 0 } 指定对话框窗口中是否显示上下文敏感的帮助图标。默认值是“yes”。   
resizable: {yes | no | 1 | 0 } 指定是否对话框窗口大小可变。默认值是“no”。
status: {yes | no | 1 | 0 } 指定对话框窗口是否显示状态栏。对于非模式对话框窗口,默认值是“yes”;对于模式对话框窗口,默认值是 “no”。

5.HTA窗口

  HTA的全名为HTML Application,翻译过来就是HTML应用程序,你只要简单的用.hta为扩展名保存HTML页面就算创建了一个HTA文件,下面我们就用HTA来编个窗口,将以下这段代码保存为.hta文件,然后再用浏览器打开。

<HTML>
<HEAD>
<TITLE>www.e3i5.com</TITLE>
<HTA:APPLICATION ID="oHTA"
APPLICATIONNAME="myApp"
  BORDER="thin"
  BORDERSTYLE="normal"
  CAPTION="yes"
  ICON="filename.ico"
  MAXIMIZEBUTTON="yes"
  MINIMIZEBUTTON="yes"
  SHOWINTASKBAR="no"
  INGLEINSTANCE="no"
  SYSMENU="yes"
  VERSION="1.0"
  WINDOWSTATE="normal" />
</HEAD>
<BODY>
<b>http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn">http://www.pconline.com.cn</b>
</BODY>
</HTML>

  有人会发现上面这些代码与平时的html有点不同,多了HTA:APPLICATION标签,这就是关键之处,hta通过它来提供一系列面向应用程序的功能,接下来再讲一讲它的属性(我的头又在发胀)
  APPLICATIONNAME属性(applicationName)
  此属性为设置HTA的名称。
  BORDER属性(border)
  此属性为设置为HTA的窗口边框类型,默认值为 thick。
  它可以设为 thick 指定窗口为粗边框
        dialog window 指定窗口为对话框
        none 指定窗口无边框
        thin 指定窗口为窄边框
  BORDERSTYLE属性(borderStyle)
  此属性为设置HTA窗口的边框格式,默认值为 normal。
  它可以设为
   normal 普通边框格式
   complex 凹凸格式组合边框
   raised 凸出的3D边框
   static 3D边框格式
   sunken 凹进的3D边框
  CAPTION属性(caption)
  此属性为设置HTA窗口是否显示标题栏或标题,默认值为 yes。
  ICON属性(icon)
  此属性为设置应用程序的图标。
  MAXIMIZEBUTTON属性(maximizeButton)
  此属性为设置是否在HTA窗口中显示最大化按钮,默认值为 yes。
  MINIMIZEBUTTON属性(minimizeButton)
  此属性为设置是否在HTA窗口中显示最小化按钮,默认值为 yes。
  SHOWINTASKBAR属性(showInTaskBar)
  此属性为设置是否在任务栏中显示此应用程序,默认值为 yes。
  SINGLEINSTANCE属性(singleInstance)
  此属性为设置是否此应用程序同时只能运行一次。次属性以APPLICATIONNAME属性作为标识,默认值为 no。
  SYSMENU属性(sysMenu)
  此属性为设置是否在HTA窗口中显示系统菜单,默认值为 yes。
  VERSION属性(version)
  此属性为设置应用程序的版本,默认值为空。
  WINDOWSTATE属性(windowState)
  此属性为设置HTA窗口的初始大小,默认值为 normal。
  它可以设为 normal 默认大小
        minmize 最小化
        maximize 最大化
  以上括号中的是在脚本引用的属性。在脚本中以上属性皆为只读属性。此外,在脚本中还可以使用commandLine属性来检索应用程序启动时的参数。
  在HTA中还可以继续使用html中的绝大多数标签、脚本等。


12、每24小时弹一次的HTML代码
你可以建立一个ads.js,下面就是这个JS文件的代码.把这个文件调用要你需要弹出广告的网页即可

function openpopup(){
document.writeln(" <SCRIPT language=&#106avascript>");
document.writeln("window.open('http://www.netbei.com">http://www.netbei.com')");
document.writeln("</script/>");
}

function get_cookie(Name) {
var search = Name + "="
var return&#118alue = "";
if (documents.cookie.length > 0) {
offset = documents.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = documents.cookie.indexOf(";", offset);
if (end == -1)
end = documents.cookie.length;
return&#118alue=unescape(documents.cookie.substring(offset, end))
}
}
return return&#118alue;
}

function helpor_net(){
if (get_cookie('popped')==''){
openpopup()
documents.cookie="popped=yes"
}
}
helpor_net()

换成你要弹出广告的URL.
 
-------------------------------------------------------------------------------
JS代码判断集锦之一 

<script language="JavaScript"> 
function checkid(iden,year,month,day){ 

if (iden.value.length==15) { 


if ((iden.value.lastIndexOf(month.value+day.value))==8) { 

return true

return false

if (iden.value.length==18) { 


if ((iden.value.indexOf(year.value+month.value+day.value))==6) { 

return true

return false


return false



function isCharsInBag (s, bag) 

var i; 
for (i = 0; i < s.length; i++

var c = s.charAt(i); 
if (bag.indexOf(c) == -1return false

return true

function isEmpty(s) 

return ((s == null|| (s.length == 0)) 


function isWhitespace (s) 

var whitespace = "  "
var i; 
for (i = 0; i < s.length; i++

var c = s.charAt(i); 
if (whitespace.indexOf(c) >= 0

return true


return false

function isEmail (s,t) 

if (isEmpty(s)) 

window.alert(
"输入的E-mail地址不能为空,请输入!"); 
mobj 
= eval(t); 
mobj.focus(); 
mobj.select(); 
return false 

if (isWhitespace(s)) 

window.alert(
"输入的E-mail地址中不能包含空格符,请重新输入!"); 
mobj 
= eval(t) 
mobj.focus() 
mobj.select() 
return false

var i = 1
var len = s.length; 

if (len > 50

window.alert(
"email地址长度不能超过50位!"); 
mobj 
= eval(t) 
mobj.focus() 
mobj.select() 
return false


pos1 
= s.indexOf("@"); 
pos2 
= s.indexOf("."); 
pos3 
= s.lastIndexOf("@"); 
pos4 
= s.lastIndexOf("."); 
if ((pos1 <= 0)||(pos1 == len)||(pos2 <= 0)||(pos2 == len)) 

window.alert(
"请输入有效的E-mail地址!"); 
mobj 
= eval(t) 
mobj.focus() 
mobj.select() 
return false

else 

if( (pos1 == pos2 - 1|| (pos1 == pos2 + 1
|| ( pos1 != pos3 ) 
|| ( pos4 < pos3 ) ) 

window.alert(
"请输入有效的E-mail地址!"); 
mobj 
= eval(t) 
mobj.focus() 
mobj.select() 
return false



if ( !isCharsInBag( s, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_@")) 

window.alert(
"email地址中只能包含字符ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_@ " + "请重新输入" ); 
mobj 
= eval(t) 
mobj.focus() 
return false

return true

function isnumber(str){ 
var digits="1234567890"
var i=0
var strlen=str.length; 
while((i<strlen)){ 
var char=str.charAt(i); 
if(digits.indexOf(char)==-1)return false;i++

return true

function isnumbercode(str){ 
var digits="1234567890-/"
var i=0
var strlen=str.length; 
while((i<strlen)){ 
var char=str.charAt(i); 
if(digits.indexOf(char)==-1)return false;i++

return true

</script> 

<script language=javascript> 
function checkForm(theform){ 
if (document.frm.companyname.value.length==0){ 
alert(
"单位名称不能为空。"); 
mobj 
= eval("document.frm.companyname"); 
mobj.focus() 
mobj.select() 
return false


if (document.frm.address.value.length==0){ 
alert(
"单位地址不能为空"); 
mobj 
= eval("document.frm.address"); 
mobj.focus() 
mobj.select() 
return false


if (document.frm.invest.value.length==0){ 
alert(
"投资额不能为空"); 
mobj 
= eval("document.frm.invest"); 
mobj.focus() 
mobj.select() 
return false

if (document.frm.codeornumber.value.length==0){ 
alert(
"法人代码证书号或营业执照编号不能为空"); 
mobj 
= eval("document.frm.codeornumber"); 
mobj.focus() 
mobj.select() 
return false


if (document.frm.linkman.value.length==0){ 
alert(
"联系人不能为空"); 
mobj 
= eval("document.frm.linkman"); 
mobj.focus() 
mobj.select() 
return false

if (document.frm.linkmanjob.value.length==0){ 
alert(
"联系人职位不能为空"); 
mobj 
= eval("document.frm.linkmanjob"); 
mobj.focus() 
mobj.select() 
return false

if (document.frm.phone.value.length==0){ 
alert(
"电话不能为空"); 
mobj 
= eval("document.frm.phone"); 
mobj.focus() 
mobj.select() 
return false


if (document.frm.email.value=='') { 
window.alert (
"请输入您的E-mail地址 !"
mobj 
= eval("document.frm.email"); 
mobj.focus() 
mobj.select() 
return false 

if ( !isEmail(document.frm.email.value,document.frm.email) ) 
return false 
if (document.frm.introduction.value.length==0){ 
alert(
"公司简介不能为空"); 
mobj 
= eval("document.frm.introduction"); 
mobj.focus() 
mobj.select() 
return false

if (document.frm.positionname.value.length==0){ 
alert(
"职位名称不能为空"); 
mobj 
= eval("document.frm.positionname"); 
mobj.focus() 
mobj.select() 
return false

if (document.frm.jobaddress.value.length==0){ 
alert(
"工作地点不能为空"); 
mobj 
= eval("document.frm.jobaddress"); 
mobj.focus() 
mobj.select() 
return false

if (document.frm.jobfunction.value.length==0){ 
alert(
"工作职责不能为空"); 
mobj 
= eval("document.frm.jobfunction"); 
mobj.focus() 
mobj.select() 
return false

if (document.frm.positionrequre.value.length==0){ 
alert(
"职位要求不能为空"); 
mobj 
= eval("document.frm.positionrequre"); 
mobj.focus() 
mobj.select() 
return false

if (document.frm.salary.value.length==0){ 
alert(
"待遇不能为空"); 
mobj 
= eval("document.frm.salary"); 
mobj.focus() 
mobj.select() 
return false


</script> 

转载至 http:
//www.tzlink.com/bbs/archiver/?tid-152.html
 
JS判断之二 转载至 http://leaf.xuann.com/blogview.asp?logid=159 

<INPUT TYPE="button" value="登录" onclick="JavaScript:login();" tabindex="4"> 

<INPUT TYPE="button" value="注册" onclick="JavaScript:regedit();" tabindex="4"> 

////////////////////////////////////////////// 

function trim(inputstr) //去处空格,在获取客户端录入的表单信息前, 
都先trim一下再提交 例如:“form1.org_name.value = trim(form1.org_name.value);” 

if(!inputstr.length>0return ""
var starts=0
var ends=inputstr.length; 
while(starts<ends) 

if(inputstr.substring(starts,starts+1)==" "
starts
++
else 
break

while(starts<ends) 

if(inputstr.substring(ends-1,ends)==" "
ends
--
else 
break

return inputstr.substring(starts,ends); 


function isvalidcode(inputs) //校验邮政编码 

var i,temp; 
var isvalidcode = true
inputstr
=trim(inputs); 
if(inputstr.length==null||inputstr.length==0||inputstr.length!=6return false
for(i=0;i<inputstr.length;i++

temp
=inputstr.substring(i,i+1); 

if(!(temp>="0" && temp<="9")) 

isvalidcode
=false
break


return isvalidcode; 


function isvalidtel(inputs) //校验电话号码 

var i,temp; 
var isvalidtel = true
inputstr
=trim(inputs); 
if(inputstr.length==null||inputstr.length==0return false
for(i=0;i<inputstr.length;i++

temp
=inputstr.substring(i,i+1); 

if(!(temp>="0" && temp<="9" || temp=="-")) 

isvalidtel
=false
break


return isvalidtel; 


function isrealnum(inputs) //校验实数(含小数点) 

var i,temp; 
var isrealnum = true
inputstr
=trim(inputs); 
if(inputstr.length==null||inputstr.length==0return false
for(i=0;i<inputstr.length;i++

temp
=inputstr.substring(i,i+1); 

if(!(temp>="0" && temp<="9" || temp==".")) 

isrealnum
=false
break


return isrealnum; 


function isnumeric(inputs) //校验是否整数 

var i,temp; 
var isnumeric = true
inputstr
=trim(inputs); 
if(inputstr.length==null||inputstr.length==0return false
//isvalid = true; 
for(i=0;i<inputstr.length;i++

temp
=inputstr.substring(i,i+1); 

if(!(temp>="0" && temp<="9")) 

isnumeric
=false
break


return isnumeric; 


function isvalidide(inputs) //校验身份证 

var i,temp; 
var isvalidide = true
inputstr
=trim(inputs); 
if(inputstr.length == null || inputstr.length == 0 || (inputstr.length != 15 && inputstr.length != 18)) return false
for(i=0;i<inputstr.length;i++

temp
=inputstr.substring(i,i+1); 

if(!((temp>="0" && temp<="9"|| temp == "x" || temp == "X")) 

isvalidide
=false
break


return isvalidide; 


function isvalidname(inputs) //校验账号2~15位(即只能是英文字母和数字组成的串) 

var i,temp; 
var isvalidname = true
inputstr
=trim(inputs); 
if(inputstr.length==null || inputstr.length==0 || inputstr.length > 15 || inputstr.length < 2return false
for(i=0;i<inputstr.length;i++

temp
=inputstr.substring(i,i+1); 

if(!((temp >= "0" && temp <= "9"|| (temp >= "a" && temp <= "z"|| (temp >= "A" && temp <= "Z"))) 

isvalidname
=false
break


return isvalidname; 


function isvalidphoto(inputs) //校验照片扩展名 

var i,temp; 
var isvalidphoto = true
inputstr
=trim(inputs); 
if(inputstr.length==null || inputstr.length==0return true//没有相片也允许的 
temp=inputstr.substring(inputstr.lastIndexOf(".")+1); 

temp 
= temp.toLowerCase(); 
if(!(temp == "bmp" || temp == "jpg" || temp == "gif")) 

isvalidphoto
=false

return isvalidphoto; 


function isvalidzgh(inputs) //校验职工号8位(即只能是英文字母和数字组成的串) 

var i,temp; 
var isvalidzgh = true
inputstr
=trim(inputs); 
if(inputstr.length==null || inputstr.length==0 || inputstr.length != 8return false
for(i=0;i<inputstr.length;i++

temp
=inputstr.substring(i,i+1); 

if(!((temp >= "0" && temp <= "9"|| (temp >= "a" && temp <= "z"|| (temp >= "A" && temp <= "Z"))) 

isvalidzgh
=false
break


return isvalidzgh; 


function isvalidxh(inputs) //校验学号7位(即只能是英文字母和数字组成的串) 

var i,temp; 
var isvalidxh = true
inputstr
=trim(inputs); 
if(inputstr.length==null || inputstr.length==0 || inputstr.length != 7return false
for(i=0;i<inputstr.length;i++

temp
=inputstr.substring(i,i+1); 

if(!((temp >= "0" && temp <= "9"|| (temp >= "a" && temp <= "z"|| (temp >= "A" && temp <= "Z"))) 

isvalidxh
=false
break


return isvalidxh; 


function isvalidkcid(inputs) //校验课程编号5位(即只能是数字组成的串) 

var i,temp; 
var isvalidkcid = true
inputstr
=trim(inputs); 
if(inputstr.length==null||inputstr.length==0||inputstr.length!=5return false
for(i=0;i<inputstr.length;i++

temp
=inputstr.substring(i,i+1); 

if(!(temp>="0" && temp<="9")) 

isvalidkcid
=false
break


return isvalidkcid; 


function isvalidnamee(inputs) //校验账号4~20位(即只能是英文字母和数字组成的串) 

var i,temp; 
var isvalidname = true
inputstr
=trim(inputs); 
if(inputstr.length==null || inputstr.length==0 || inputstr.length > 20 || inputstr.length < 4return false
for(i=0;i<inputstr.length;i++

temp
=inputstr.substring(i,i+1); 

if(!((temp >= "0" && temp <= "9"|| (temp >= "a" && temp <= "z"|| (temp >= "A" && temp <= "Z"))) 

isvalidname
=false
break


return isvalidname; 



========================== 

<Script language="JavaScript"> 
function login() 

form1.UNAME.value 
= trim(form1.UNAME.value); 
form1.PWD.value 
= trim(form1.PWD.value); 
form1.PWD2.value 
= trim(form1.PWD2.value); 
form1.EMAIL.value 
= trim(form1.EMAIL.value); 
form1.NC.value 
= trim(form1.NC.value); 
if(!isvalidname(form1.UNAME.value)) 

alert(
"请您注意:用户名必须为『2~15位英文或数字』!"); 
form1.UNAME.focus(); 
return false

else if(!isvalidname(form1.PWD.value)) 

alert(
"请您注意:密码必须为『2~15位英文或数字』!"); 
form1.PWD.focus(); 
return false

else if(!isvalidname(form1.PWD2.value)) 

alert(
"请您注意:密码确认也必须为『2~15位英文或数字』!"); 
form1.PWD2.focus(); 
return false

else if(form1.PWD.value != form1.PWD2.value) 

alert(
"两次密码不一致!"); 
form1.PWD.focus(); 
return false

else if(form1.EMAIL.value == "" || form1.EMAIL.value.length > 100

alert(
"请输入邮件!"); 
form1.EMAIL.focus(); 
return false

else if(form1.NC.value == "" || form1.NC.value.length > 15

alert(
"请输入昵称!"); 
form1.NC.focus(); 
return false

else if(window.confirm("您确信提交!")) 
return true
else 
return false


function regedit() 

var litop = (screen.height - 162)/2
var lileft = (screen.width - 360)/2
window.open(
"/regedit.aspx""reg""titlebar=no,fullscreen=no,dependent=yes,height=162,width=360, 
top=
" + litop + ",left=" + lileft + "
toolbar=no,menubar=no,scrollbars=no,resizable=no, 
channelmode=no,status=no,location=no,directories=no
"); 

</Script>
 
不许复制(copy),不许用鼠标右键! 

<SCRIPT> 
//加入页面保护 
function rf() 
{
return false; } 
document.oncontextmenu 
= rf 
function keydown() 
{
if(event.ctrlKey ==true || event.keyCode ==93 || event.shiftKey ==true){return false;} } 
document.onkeydown 
=keydown 
function drag() 
{
return false;} 
document.ondragstart
=drag 
function stopmouse(e) { 
if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) 
return false
else if 
(navigator.appName 
== 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) { 
alert(
"版权没有,但别复制 :)"); 
return false

return true

document.onmousedown
=stopmouse; 
if (document.layers) 
window.captureEvents(Event.MOUSEDOWN); 
window.onmousedown
=stopmouse; 

</SCRIPT> 
<script language="javascript"> 
function JM_cc(ob){ 
var obj=MM_findObj(ob); if (obj) { 
obj.select();js
=obj.createTextRange();js.execCommand("Copy");} 


function MM_findObj(n, d) { //v4.0 
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { 
d
=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} 
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; 
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); 
if(!&& document.getElementById) x=document.getElementById(n); return x; 

</script>

 1.[普通效果]
    现在很多网站广告做的如火如荼,现在我就来介绍一下常见的对联浮动广告效果的代码使用方法,介绍的这种效果,在1024*768分辨率下正常显示,在800*600的分辨率下可以自动隐藏,以免遮住页面影响访问者浏览内容,下面就是实现效果所需代码:

var delta=0.015 
    
var collection; 
    
function floaters() { 
    
this.items = []; 
    
this.addItem = function(id,x,y,content) 
    { 
    document.write(
'<DIV id='+id+' style="Z-INDEX: 0; POSITION: absolute; width:80px; height:60px;left:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>'); 
    
    
var newItem = {}; 
    newItem.object 
= document.getElementById(id); 
    newItem.x 
= x; 
    newItem.y 
= y; 
    
    
this.items[this.items.length] = newItem; 
    } 
    
this.play = function() 
    { 
    collection 
= this.items 
    setInterval(
'play()',10); 
    } 
    } 
    
function play() 
    { 
    
if(screen.width<=800
    { 
    
for(var i=0;i<collection.length;i++
    { 
    collection.object.style.display 
= 'none'
    } 
    
return
    } 
    
for(var i=0;i<collection.length;i++
    { 
    
var followObj = collection.object; 
    
var followObj_x = (typeof(collection.x)=='string'?eval(collection.x):collection.x); 
    
var followObj_y = (typeof(collection.y)=='string'?eval(collection.y):collection.y); 
    
    
if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x)) { 
    
var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta; 
    dx
=(dx>0?1:-1)*Math.ceil(Math.abs(dx)); 
    followObj.style.left
=followObj.offsetLeft+dx; 
    } 
    
    
if(followObj.offsetTop!=(document.body.scrollTop+followObj_y)) { 
    
var dy=(document.body.scrollTop+followObj_y-followObj.offsetTop)*delta; 
    dy
=(dy>0?1:-1)*Math.ceil(Math.abs(dy)); 
    followObj.style.top
=followObj.offsetTop+dy; 
    } 
    followObj.style.display 
= ''
    } 
    } 
    
    
var theFloaters = new floaters(); 
    theFloaters.addItem(
'followDiv1','document.body.clientWidth-100',0,'</a><br><a href=广告链接地址 target=_blank><img src=广告图片地址 width=100 height=400 border=0></a>' target=_blank); 
    theFloaters.addItem(
'followDiv2',0,0,'<br><a href=广告链接地址 target=_blank><img src=广告图片地址 width=100 height=400 border=0></a>' target=_blank); 
    theFloaters.play(); 
把上面的代码另存为一个JS文件,然后在想实现此效果的页面用 调用即可!注意修改广告图片地址和连接地址!
 
2.[鼠标感应]
    与前面一个代码不同的是,当鼠标移动到广告图片上是可以感应显示另外设置好的广告大图效果,下面就是实现效果所需代码:
 
function bigshow(){ 
    document.all.div_250.style.visibility 
= 'visible'
    document.all.div_80.style.visibility 
= 'hidden'
    } 
    
function bighide(){ 
    document.all.div_80.style.visibility 
= 'visible'
    document.all.div_250.style.visibility 
= 'hidden'
    } 
    
    
var ad_80= new Array(1); 
    
var ad_250= new Array(1); 
    
    ad_80[
0]="<a href=http://www.dfeng.net target=_blank><img src=/skin/adv43/ad/ad_ad.gif border=0></a>"
    ad_250[
0]="<a href=http://www.dfeng.net target=_blank><img src=/skin/adv43/ad/ad_ad2.gif border=0></a>"
    
    
var imgheight; 
    
var fubioleft; 
    window.screen.width
>800 ? fubioleft=15:fubioleft=15 
    
    document.write(
'<DIV id=floater_left style="Z-INDEX: 25; LEFT:'+fubioleft+'px; WIDTH: 28px;POSITION: absolute; TOP: 42px; HEIGHT: 22px">'); 
    
    ad_now 
= new Date(); 
    ad_id
= ad_now.getSeconds() %1 
    
    
var adhead1="<div id=div_80 style='position:absolute; width:95px; height:62px; z-index:12' onMouseOver=bigshow();>"
    
var adhead2="</div><div id=div_250 style='position:absolute; visibility: hidden; z-index:13;width: 80; height: 60' onMouseOut=bighide();>"
    
    
//var adhead1="<div id=div_80 style='position:absolute; width:95px; height:62px; z-index:20' onMouseOut='//MM_showHideLayers("div_250","","hide")' onMouseOver='MM_showHideLayers("div_250","","show")'>"; 
    //var adhead2="</div><div id=div_250 style='position:absolute; z-index:21;visibility: hidden; width: 80; height: 60' onMouseOver='MM_showHideLayers("div_250","","show")' onMouseOut='MM_showHideLayers("div_250","","hide")'>"; 
    
    document.write(adhead1
+ad_80[ad_id]+adhead2+ad_250[ad_id]+"</div>"); 
    
    document.write (
"</div>"); 
    self.onError
=null
    currentX 
= currentY = 0
    whichIt 
= null
    lastScrollX 
= 0; lastScrollY = 0
    NS 
= (document.layers) ? 1 : 0
    IE 
= (document.all) ? 10
    
function heartBeat() { 
    
if(IE) { 
    diffY 
= document.body.scrollTop; 
    diffX 
= document.body.scrollLeft; } 
    
if(NS) { 
    diffY 
= self.pageYOffset; diffX = self.pageXOffset; } 
    
if(diffY != lastScrollY) { 
    percent 
= .5 * (diffY - lastScrollY); 
    
if(percent > 0) percent = Math.ceil(percent); 
    
else percent = Math.floor(percent); 
    
if(IE) document.all.floater_left.style.pixelTop += percent; 
    
if(NS) document.floater_left.top += percent; 
    lastScrollY 
= lastScrollY + percent; 
    } 
    
if(diffX != lastScrollX) { 
    percent 
= .5 * (diffX - lastScrollX); 
    
if(percent > 0) percent = Math.ceil(percent); 
    
else percent = Math.floor(percent); 
    
if(IE) document.all.floater_left.style.pixelLeft += percent; 
    
if(NS) document.floater_left.left += percent; 
    lastScrollX 
= lastScrollX + percent; 
    } 
    } 
    
    
if(NS || IE) action = window.setInterval("heartBeat()",1);var ad_80= new Array(1); 
    
var ad_250= new Array(1); 
    
    ad_80[
0]="<a href=http://www.dfeng.net target=_blank><img src=/skin/adv43/ad/ad_ad.jpg border=0></a>"
    ad_250[
0]="<a href=http://www.dfeng.net target=_blank><img src=/skin/adv43/ad/ad_ad.jpg border=0></a>"
    
    
var imgheight; 
    
var fubioleft; 
    window.screen.width
>800 ? fubioleft=15:fubioleft=15 
    
    document.write(
'<DIV id=floater_right style="Z-INDEX: 25; LEFT:'+fubioleft+'px; WIDTH: 28px;POSITION: absolute; TOP: 42px; HEIGHT: 22px">'); 
    
    ad_now 
= new Date(); 
    ad_id
= ad_now.getSeconds() %1 
    
    
function myload() 
    { 
    
if (navigator.appName == "Netscape"
    { 
    document.div_right_80.pageX
=+window.innerWidth-130
    document.div_right_250.pageX
=+window.innerWidth-300
    mymove(); 
    } 
    
else 
    { 
    div_right_80.style.left
=document.body.offsetWidth-130
    div_right_250.style.left
=document.body.offsetWidth-300
    mymove(); 
    } 
    } 
    
    
function mymove() 
    { 
    
if(document.ns) 
    { 
    document.div_right_80.left
=pageXOffset+window.innerWidth-130
    document.div_right_250.left
=pageXOffset+window.innerWidth-300
    setTimeout(
"mymove();",20
    } 
    
else 
    { 
    div_right_80.style.left
=document.body.scrollLeft+document.body.offsetWidth-145
    div_right_250.style.left
=document.body.scrollLeft+document.body.offsetWidth-300
    setTimeout(
"mymove();",20
    } 
    } 
    
    
var adhead1="<div id=div_right_80 style='position:absolute; width:95px; height:60px; z-index:12' onMouseOver=bigshow_right();>"
    
var adhead2="</div><div id=div_right_250 style='position:absolute; visibility: hidden; z-index:13;width: 250; height: 250' onMouseOut=bighide_right();><div align=right>"
    
    document.write(adhead1
+ad_80[ad_id]+adhead2+ad_250[ad_id]+"</div></div>"); 
    
    myload() 
    
    document.write (
"</div>"); 
    self.onError
=null
    currentX_right 
= currentY_right = 0
    whichIt_right 
= null
    lastScrollX_right 
= 0; lastScrollY_right = 0
    NS 
= (document.layers) ? 1 : 0
    IE 
= (document.all) ? 10
    
function heartBeat_right() { 
    
if(IE) { 
    diffY_right 
= document.body.scrollTop; 
    diffX_right 
= document.body.scrollLeft; } 
    
if(NS) { 
    diffY_right 
= self.pageYOffset; diffX_right = self.pageXOffset; } 
    
if(diffY_right != lastScrollY_right) { 
    percent_right 
= .5 * (diffY_right - lastScrollY_right); 
    
if(percent_right > 0) percent_right = Math.ceil(percent_right); 
    
else percent_right = Math.floor(percent_right); 
    
if(IE) document.all.floater_right.style.pixelTop += percent_right; 
    
if(NS) document.floater_right.top += percent_right; 
    lastScrollY_right 
= lastScrollY_right + percent_right; 
    } 
    
if(diffX_right != lastScrollX_right) { 
    percent_right 
= .5 * (diffX_right - lastScrollX_right); 
    
if(percent_right > 0) percent_right = Math.ceil(percent_right); 
    
else percent_right = Math.floor(percent_right); 
    
if(IE) document.all.floater_right.style.pixelLeft += percent_right; 
    
if(NS) document.floater_right.left += percent_right; 
    lastScrollX_right 
= lastScrollX_right + percent_right; 
    } 
    } 
    
    
if(NS || IE) action = window.setInterval("heartBeat_right()",1); 
    
function bigshow_right(){ 
    document.all.div_right_250.style.visibility 
= 'visible'
    document.all.div_right_80.style.visibility 
= 'hidden'
    } 
    
function bighide_right(){ 
    document.all.div_right_80.style.visibility 
= 'visible'
    document.all.div_right_250.style.visibility 
= 'hidden'
    }document.write(
''); 
    document.write(
''); 
    document.write(
''); 

 把上面的代码另存为一个JS文件,然后在想实现此效果的页面用
   
    <script type="text/javascript" language="javascript1.2" src="*.js"></SCRIPT>
   
    调用即可,*代表你另存的文件名!注意修改广告图片地址和连接地址!
   
    3.[允许关闭]
    与前面两个代码不同的是,广告图下方增加了一个图片按纽,允许访客点击关闭广告图片,下面文本框中就是实现效果所需代码:

 

var delta=0.015
    
var collection; 
    
var closeB=false
    
function floaters() { 
    
this.items = []; 
    
this.addItem = function(id,x,y,content) 
    { 
    document.write(
'<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute; width:80px; height:60px;left:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>'); 
    
    
var newItem = {}; 
    newItem.object 
= document.getElementById(id); 
    newItem.x 
= x; 
    newItem.y 
= y; 
    
    
this.items[this.items.length] = newItem; 
    } 
    
this.play = function() 
    { 
    collection 
= this.items 
    setInterval(
'play()',30); 
    } 
    } 
    
function play() 
    { 
    
if(screen.width<=800 || closeB) 
    { 
    
for(var i=0;i<collection.length;i++
    { 
    collection.object.style.display 
= 'none'
    } 
    
return
    } 
    
for(var i=0;i<collection.length;i++
    { 
    
var followObj = collection.object; 
    
var followObj_x = (typeof(collection.x)=='string'?eval(collection.x):collection.x); 
    
var followObj_y = (typeof(collection.y)=='string'?eval(collection.y):collection.y); 
    
    
if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x)) { 
    
var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta; 
    dx
=(dx>0?1:-1)*Math.ceil(Math.abs(dx)); 
    followObj.style.left
=followObj.offsetLeft+dx; 
    } 
    
    
if(followObj.offsetTop!=(document.body.scrollTop+followObj_y)) { 
    
var dy=(document.body.scrollTop+followObj_y-followObj.offsetTop)*delta; 
    dy
=(dy>0?1:-1)*Math.ceil(Math.abs(dy)); 
    followObj.style.top
=followObj.offsetTop+dy; 
    } 
    followObj.style.display 
= ''
    } 
    } 
    
function closeBanner() 
    { 
    closeB
=true
    
return
    } 
    
    
var theFloaters = new floaters(); 
    
// 
    theFloaters.addItem('followDiv1','document.body.clientWidth-100',0,'<a onClick="closeBanner();" href=http://www.dfeng.net target=_blank><img src=ad/doublead/right.gif width=100 height=554 border=0></a><br><br><img src=ad/doublead/close.gif onClick="closeBanner();">'); 
    theFloaters.addItem(
'followDiv2',0,0,'<a onClick="closeBanner();" href=http://www.dfeng.net target=_blank><img src=ad/doublead/ad_ad.gif width=100 height=400 border=0 ></a><br><br><img src=ad/doublead/close.gif onClick="closeBanner();">'); 
    theFloaters.play(); 

把上面的代码另存为一个JS文件,然后在想实现此效果的页面用 调用即可,*代表你另存的文件名!注意修改广告图片地址和连接地址!
   
    4.[浮动对联广告---之左侧代码]
   
    如果您想只有一侧显示的话,下面是实现左侧效果所需代码:

 

<script language="javascript"> 
    
<!-- 
    
var sohu=window.open('http://www.sohu.com'); 
    
var ads=window.open('about:blank','ads','width=700,height=400'); 
    sohu.focus(); 
    ads.document.open(); 
    ads.document.write (
"<html><head><title>ads</title></head><body>This is background ads</body></html>"); 
    ads.document.close(); 
    
//--> 
    </script> 
    
    
6.收缩广告 
    
    
<script language="javascript"> 
    
<!-- 
    
var bwidth=800
    
var bheight=400
    
function go() { 
    bwidth 
= bwidth - 10
    bheight 
= bheight - 5
    
if(bwidth <= 10
    { ads.style.display
='none';clearTimeout("my"); } 
    
else 
    { ads.outerHTML
='<span id="ads" style="width:'+bwidth+'px;height:'+bheight+'px;background-color:#0099FF;"></span>';} 
    
var my=setTimeout("go()",50); 
    } 
    setTimeout(
"go()",6000); 
    
//--> 
    </script> 
    
<body topmargin="0" leftmargin="0"> 
    
<div align="center"><span id="ads" style="width:800px;height:400px;background-color:#0099FF"></span></div> 
    
</body> 

JavaScript基础知识

<a target="_new" href="http://www.cnblogs.com/meil/archive/2006/07/27/460506.html">http://www.cnblogs.com/meil/archive/2006/07/27/460506.html</a>

js幻灯片播放器

var _c = 0;
var _i = 0;
var _v = 0;
var _l = 0;
var _sf = 3000;
var _html = null;
var _image = null;
var _mycars= new Array();
var _w = new Array();
var _h = new Array();

function adRotator() {}

function adRotator.add(p,w,h)
{
   _mycars[_c] 
= p;
   _w[_c] 
= w;
   _h[_c] 
= h;
   _c 
= _c + 1;
}


/* 播放设置 */
function  adRotator.loads()
{
   
if (_i < _mycars.length && _l < 1)
   
{
     _html 
= '<img src="' + _mycars[_i] + '" width="' + _w[_i] + '" height="' + _h[_i] + '" style="border:1px solid #CCCCCC;">'
     
if (_v < 1)
     
{
        document.getElementById(
'image').value = _html + ',' + _i;
        document.getElementById(
'rotatorPlayer').innerHTML = _html;
        _i 
= _i + 1;
  document.getElementById(
'backs').disabled='';
        window.setTimeout(
"adRotator.loads("+_i+")",_sf);
     }

   }

   
else
   
{
     _html 
= '<img src="' + _mycars[_i] + '" width="' + _w[_i] + '" height="' + _h[_i] + '" style="border:1px solid #CCCCCC;">'
  document.getElementById(
'image').value = _html + ',' + _i;
     document.getElementById(
'rotatorPlayer').innerHTML = _html;
   }

   
if (_i+1 > _mycars.length)
   
{
      document.getElementById(
'stops').disabled='True';
   document.getElementById(
'play').disabled='';
   document.getElementById(
'backs').disabled='';
   document.getElementById(
'next').disabled='True';
   _i 
= 0;
   _v 
= 1;
   }

}


/* 播放 */
function  adRotator.play()
{
   _v 
= 0;
   _l 
= 0;
   adRotator.loads();
}


/* 下一张 */
function adRotator.next()
{
   _l 
= 1;
   
if(_i+1 < _mycars.length)
   
{
      _i 
= _i + 1;
   document.getElementById(
'play').disabled='';
   document.getElementById(
'stops').disabled='True';
   document.getElementById(
'backs').disabled='';
   adRotator.loads();
   }

   
else
   
{
      document.getElementById(
'next').disabled='True';
   }

}


/* 上一张 */
function adRotator.backs()
{
   _l 
= 1;
   
if(_i-1 < 0)
   
{
      document.getElementById(
'backs').disabled='True';
   }

   
else
   
{
      _i 
= _i - 1;
   document.getElementById(
'play').disabled='';
   document.getElementById(
'stops').disabled='True';
   document.getElementById(
'next').disabled='';
   adRotator.loads();
   }

}


/* 间隔时间 */
function adRotator.set()
{
   
var _sfc = document.getElementById('second').value;
   
if (isInteger(_sfc))
   
{
     _sf 
= _sfc * 1000;
   }

   
else
   
{
     alert(
'提示:只能输入数字!');
     document.getElementById(
'second').value=1;
     document.getElementById(
'second').select();
   }

}


/* 字符检测 */
function isInteger(str)
{  
  
var regu = /^[-]{0,1}[0-9]{1,}$/;
  
return regu.test(str);
}


/* 暂停 */
function adRotator.stops()
{
   _v 
= 1;
}


/* 添加图片,还要加的话注意图片名字就好了,后面400,300是大小 */
adRotator.add(
"1.jpg",400,300);
adRotator.add(
"2.jpg",400,300);
adRotator.add(
"3.jpg",400,300);


把以上文件存为一个JS文件

在下面文件中引用即可

<style type="text/css">
<!--
body 
{ font-size:12px;
}

input 

    border
-right: #7b9ebd 1px solid;
 padding
-right: 2px;
 border
-top: #7b9ebd 1px solid;
 padding
-left: 2px;
 font
-size: 12px;
 filter: progid:DXImageTransform.Microsoft.Gradient(GradientType
=0, StartColorStr=#ffffff, EndColorStr=#cecfde);
 border
-left: #7b9ebd 1px solid;
 cursor: hand;
 color: black;
 padding
-top: 2px;
 border
-bottom: #7b9ebd 1px solid;
}

button 

    border
-right: #7b9ebd 1px solid;
 padding
-right: 2px;
 border
-top: #7b9ebd 1px solid;
 padding
-left: 2px;
 font
-size: 12px;
 filter: progid:DXImageTransform.Microsoft.Gradient(GradientType
=0, StartColorStr=#ffffff, EndColorStr=#cecfde);
 border
-left: #7b9ebd 1px solid;
 cursor: hand;
 color: black;
 padding
-top: 2px;
 border
-bottom: #7b9ebd 1px solid;
}

-->
</style>
<script language="javascript" src="test.js">
</script>

     
<body onLoad="adRotator.play();">
<div id="rotatorPlayer"></div>

 

<input type="button" name="play" value="开始播放" onClick="adRotator.play();this.disabled='true';document.getElementById('stops').disabled=''" disabled="True"/>
<input type="button" name="stops" value="暂停" onClick="adRotator.stops();this.disabled='true';document.getElementById('play').disabled=''"/>
<input type="button" name="backs" value="上一张" onClick="adRotator.backs();" disabled="true"/>
<input type="button" name="next" value="下一张" onClick="adRotator.next();"/>&nbsp;&nbsp;&nbsp;
<input type="text" id="second" value="3" size="3" maxlength="2">

<input type="button" value="设置时间" onClick="adRotator.set()" />

 

<input name="image" type="text" size="65"/>


一个非常棒的播放器,可惜如果图片是非常大的话,那结果有点惨
!

动态时钟,秒秒都跳的哦

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>js核心对象之Date</title>
<script type="text/javascript">
function startTime()
{
var today=new Date()//定义一个时间对象
var h=today.getHours()//定义小时
var m=today.getMinutes()//定义分钟
var s=today.getSeconds()//定义秒
//
 add a zero in front of numbers<10
m=checkTime(m)//把分给checkTime处理
s=checkTime(s)//把秒给checkTime处理
document.getElementById('txt').innerHTML=h+":"+m+":"+s//在层txt中显示
t=setTimeout('startTime()',500)
}

function checkTime(i)
{
//这函数意思很简单了,就是要实现01-09的效果
if (i<10//
  {i="0" + i}
  
return i
}
</script>
</head>

<body onload="startTime()">
<div id="txt"></div>
</body>
</html>
新年&圣诞倒记时js代码  网上转载的,具体转载请在AJAX&javascript入门系列教程里面关于Date对象的演示里面查找
[color=Red]新年倒记时js代码[/color]
在index.htm 查找
[code]$navigation
</td>[/code]

前面加上
[code]
<!--2006年新年倒记时js代码显示开始-->
<BODY TEXT="000000" onLoad="clock()">
<SPAN id="Clock"></SPAN>
<SCRIPT LANGUAGE="JavaScript"><!--
function clock() {
if (!document.layers && !document.all) return;
  today 
= new Date();
  intDate 
= today.getDate();
  intHours 
= today.getHours();
  intMinutes 
= today.getMinutes();
  intSeconds 
= today.getSeconds();
  intMonth 
= today.getMonth()+1 ;
  intYear 
= today.getYear();
  hours 
= intHours;
  hours 
= (23 - hours);
  minutes 
= intMinutes;
  minutes 
= (59 - minutes);
  seconds 
= intSeconds;
  seconds 
= (59 - seconds);

if (intYear % 4 == 0 && intYear % 100 != 0 || intYear % 400 == 0)
if (intMonth == 1)  {month = "距2006年新年还有"; date = (366 - intDate);}
  
if (intMonth == 2)  {month = "距2006年新年还有"; date = (335 - intDate);}
}
else
if (intMonth == 1)  {month = "距2006年新年还有"; date = (365 - intDate);}
  
if (intMonth == 2)  {month = "距2006年新年还有"; date = (334 - intDate);}
}

  
if (intMonth == 3)  {month = "距2006年新年还有"; date = (304 - intDate);}
  
if (intMonth == 4)  {month = "距2006年新年还有"; date = (273 - intDate);}
  
if (intMonth == 5)  {month = "距2006年新年还有"; date = (243 - intDate);}
  
if (intMonth == 6)  {month = "距2006年新年还有"; date = (212 - intDate);}
  
if (intMonth == 7)  {month = "距2006年新年还有"; date = (182 - intDate);}
  
if (intMonth == 8)  {month = "距2006年新年还有"; date = (152 - intDate);}
  
if (intMonth == 9)  {month = "距2006年新年还有"; date = (121 - intDate);}
  
if (intMonth == 10) {month = "距2006年新年还有"; date = (91 - intDate);}
  
if (intMonth == 11) {month = "距2006年新年还有"; date = (60 - intDate);}
  
if (intMonth == 12) {month = "距2006年新年还有"; date = (30 - intDate);}

  
if (date == 1 ){date = ("0"+date+"天  ");}
  
if (date != 1 && date < 10 && date >=0){date = ("0"+date+"");}
  
if (date > 9){date = (date+"");}

  
if (hours ==1 ){hours = ("0"+hours+"小时");}
  
if (hours != 1 && hours < 10){hours = ("0"+hours+"小时");}
  
if (hours > 9){hours = (hours+"小时");}

  
if (minutes == 1){minutes = ("0"+minutes+"分  ");}
  
if (minutes != 1 && minutes < 10){minutes = ("0"+minutes+"");}
  
if (minutes > 9){minutes = (minutes+"");}

  
if (seconds == 1){seconds = ("0"+seconds+"秒 "+"!");}
  
if (seconds != 1 && seconds < 10){seconds = ("0"+seconds+"秒!");}
  
if (seconds > 9){seconds = (seconds+"秒!");}

  
if (date < 0){month = "Happy";date = " New year!";hours = " 新年";minutes = "快乐";seconds = "!";}
  timeString 
= month+date+hours+minutes+seconds;


if (document.layers) {
document.layers.Clock.document.write(timeString);
document.layers.Clock.document.close();
}
else
if (document.all)
Clock.innerHTML 
= timeString;
setTimeout(
"clock()"1000);
}
//--></script>

<!--2006年新年倒记时js代码结束-->
[
/code]

[color
=Red]圣诞倒计时JS代码[/color]
在index.htm 查找
[code]$navigation
</td>[/code]
前面加上
[code]
<!-- 圣诞倒计时JS代码 开始 -->
<BODY TEXT="000000" onLoad="clock()">
<SPAN id="Clock"></SPAN>
<SCRIPT LANGUAGE="JavaScript"><!--
function clock() {
if (!document.layers && !document.all) return;
  today 
= new Date();
  intDate 
= today.getDate();
  intHours 
= today.getHours();
  intMinutes 
= today.getMinutes();
  intSeconds 
= today.getSeconds();
  intMonth 
= today.getMonth()+1 ;
  intYear 
= today.getYear();
  hours 
= intHours;
  hours 
= (23 - hours);
  minutes 
= intMinutes;
  minutes 
= (59 - minutes);
  seconds 
= intSeconds;
  seconds 
= (59 - seconds);

if (intYear % 4 == 0 && intYear % 100 != 0 || intYear % 400 == 0)
if (intMonth == 1)  {month = "距圣诞节还有"; date = (359 - intDate);}
  
if (intMonth == 2)  {month = "距圣诞节还有"; date = (328 - intDate);}
}
else
if (intMonth == 1)  {month = "距圣诞节还有"; date = (358 - intDate);}
  
if (intMonth == 2)  {month = "距圣诞节还有"; date = (327 - intDate);}
}

  
if (intMonth == 3)  {month = "距圣诞节还有"; date = (299 - intDate);}
  
if (intMonth == 4)  {month = "距圣诞节还有"; date = (268 - intDate);}
  
if (intMonth == 5)  {month = "距圣诞节还有"; date = (238 - intDate);}
  
if (intMonth == 6)  {month = "距圣诞节还有"; date = (207 - intDate);}
  
if (intMonth == 7)  {month = "距圣诞节还有"; date = (177 - intDate);}
  
if (intMonth == 8)  {month = "距圣诞节还有"; date = (146 - intDate);}
  
if (intMonth == 9)  {month = "距圣诞节还有"; date = (115 - intDate);}
  
if (intMonth == 10) {month = "距圣诞节还有"; date = (85 - intDate);}
  
if (intMonth == 11) {month = "距圣诞节还有"; date = (54 - intDate);}
  
if (intMonth == 12) {month = "距圣诞节还有"; date = (24 - intDate);}

  
if (date == 1 ){date = ("0"+date+"天  ");}
  
if (date != 1 && date < 10 && date >=0){date = ("0"+date+"");}
  
if (date > 9){date = (date+"");}

  
if (hours ==1 ){hours = ("0"+hours+"小时");}
  
if (hours != 1 && hours < 10){hours = ("0"+hours+"小时");}
  
if (hours > 9){hours = (hours+"小时");}

  
if (minutes == 1){minutes = ("0"+minutes+"分  ");}
  
if (minutes != 1 && minutes < 10){minutes = ("0"+minutes+"");}
  
if (minutes > 9){minutes = (minutes+"");}

  
if (seconds == 1){seconds = ("0"+seconds+"秒 "+"!");}
  
if (seconds != 1 && seconds < 10){seconds = ("0"+seconds+"秒!");}
  
if (seconds > 9){seconds = (seconds+"秒!");}

  
if (date < 0){month = "Merry ";date = " Christmas! ";hours = " 圣诞";minutes = "快乐";seconds = "!";}
  timeString 
= month+date+hours+minutes+seconds;


if (document.layers) {
document.layers.Clock.document.write(timeString);
document.layers.Clock.document.close();
}
else
if (document.all)
Clock.innerHTML 
= timeString;
setTimeout(
"clock()"1000);
}
//--></script>
<!-- 圣诞倒计时JS代码 结束 -->
[
/code]

在footer.htm 查找
[code]
<tr class="altbg1"><td>{lang time_now}[/code]

加上以上代码
 
原创粉丝点击