导航:首页 > 源码编译 > settimeout源码

settimeout源码

发布时间:2022-08-21 04:31:11

A. 求网页顶端网页自动展开之后能关闭的网页广告源码

<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<style>
html,body{margin:0;font-size:12px}img{border:none}p{border-top:5px solid#660000;padding:40px;background:#999900;height:1500px;margin:0px}
</style>
<script>
var showAD = {
curve: function(t, b, c, d, s) {
if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
return c / 2 * ((t -= 2) * t * t + 2) + b
},
fx: function(from, to, playTime, onEnd) {
var Me = this,
who = this.adWrap,
position = 0,
changeVal = to - from,
curve = this.curve;
playTime = playTime / 10;
who.style.overflow = 'hidden';
function _run() {
if (position++<playTime) {
who.style.height = Math.max(1, Math.abs(Math.ceil(curve(position, from, changeVal, playTime)))) + "px";
setTimeout(_run, 10)
} else {
onEnd && onEnd.call(Me, to)
}
};
_run()
},
init: function(info) {
var Me = this,
loadImg = new Image;
loadImg.src = info.endImgURL;
window.onload=function() {
Me.endImgURL = info.endImgURL;
Me.img = document.getElementById(info.imgID);
Me.adWrap = document.getElementById(info.adWrapID);
var max = Me.img.height;
setTimeout(function() {
Me.fx(max, 0, 500,
function(x) {
this.img.src = this.endImgURL;
this.curve = function(t, b, c, d) {
if ((t /= d) < (1 / 2.75)) {
return c * (7.5625 * t * t) + b
} else if (t < (2 / 2.75)) {
return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b
} else if (t < (2.5 / 2.75)) {
return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b
} else {
return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b
}
};
this.fx(0, this.img.height,600)
})
},
info.timeout || 1000)
};
}
};
showAD.init({
adWrapID: 'ad_box_2009_04',
imgID: 'adImg',
endImgURL: 'http://c1.neweggimages.com.cn/NeweggPic2/Marketing/200906/hot/a.jpg'
});
</script>
</head>

<body>
<div id="ad_box_2009_04" style="background:BF0008">
<img src="http://c1.neweggimages.com.cn/NeweggPic2/Marketing/200906/hot/b.jpg" id="adImg" />
</div>

</body>
</html>

B. setTimeout;函数调用时 为什么显示未定义

这个对话框必须要用模拟的那种【用div做一个对话框,网上有很多源码】,不能直接alert()这样用函数会暂停运行。我的思路是 在函数开始执行时 显示对话框。结束时因藏对话框。function XX(){showing();你的程序####close();}

C. 用天、小时的倒记时源代码怎么写,谁有给一个呀,在下不胜感激了!!!

<html>
<head>
<title>倒计时</title>
<style>
.time{color:#ffffff;font-family:verdana,geneva,helveticafont-size:9pt}
a:link{text-decoration:none;color:#000000}
a:active{text-decoration:none;color:#000000}
a:visited{text-decoration:none;color:#000000}
a:hover{text-decoration:none;color:#000000}
</style>

<script language="javascript">

var time_now_server,time_now_client,time_end,time_server_client,timerID;

time_end=new Date("Jan 20, 2002 00:00:00");
time_end=time_end.getTime();

time_now_server=new Date("Dec 21, 2001 13:11:1");
time_now_server=time_now_server.getTime();

time_now_client=new Date();
time_now_client=time_now_client.getTime();

time_server_client=time_now_server-time_now_client;

setTimeout("show_time()",1000);

function show_time()
{
timer.innerHTML =time_server_client;

var time_now,time_distance,str_time;
var int_day,int_hour,int_minute,int_second;
var time_now=new Date();
time_now=time_now.getTime()+time_server_client;
time_distance=time_end-time_now;
if(time_distance>0)
{
int_day=Math.floor(time_distance/86400000)
time_distance-=int_day*86400000;
int_hour=Math.floor(time_distance/3600000)
time_distance-=int_hour*3600000;
int_minute=Math.floor(time_distance/60000)
time_distance-=int_minute*60000;
int_second=Math.floor(time_distance/1000)

if(int_hour<10)
int_hour="0"+int_hour;
if(int_minute<10)
int_minute="0"+int_minute;
if(int_second<10)
int_second="0"+int_second;
str_time="<font style='font-size:14pt;color:#28C84A'>"+int_day+"</font><font face='黑体' style='font-size:13pt;'>天</font><br>"+int_hour+":"+int_minute+":"+int_second;
timer.innerHTML=str_time;
setTimeout("show_time()",1000);
}
else
{
timer.innerHTML ="over";
clearTimeout(timerID)
}
}
</script>
<style>
.time{color:#000000;font-family:verdana;font-size:9pt}
</style>
</head>

<BODY BGCOLOR=#FFFFFF topmargin=2 leftmargin=2>
<div id="Layer1" style="position:absolute; width:160px; height:187px; z-index:1">
<!-- begin calendar -->
<table width=160 border=0 cellpadding=0 cellspacing=0>
<tr>
<td colspan=3> </td>
</tr>
<tr>
<td width="47"> </td>
<td background="images/mail_03.gif" width="67" valign="top">
<table width=65 cellpadding=3 cellspacing=0 border=0>
<tr>
<td align=center class="time">
<a href="http://203.212.7.76:8000/Announcement.html" target=_blank><div id="timer" style="font-size:9pt;color:red"></div></a>
</td>
</tr>
</table>
</td>
<td width="46"> </td>
</tr>
<tr>
<td colspan=3> </td>
</tr>
</table>
<!-- end calendar -->
</div>
</BODY>
</HTML>

D. 用js源码做出缓动效果,关于for循环和settimeout

因为你定义了200个定时器

从第一个到最后一个定时器
每个休息的时间是i的25倍
而i从0到200改变
因此
定时器的休息时间越来越久
于是看得到移动的效果
不然就一起移动了,看不到效果,因为都是最后的那个200

E. 时间倒计时代码

http://bbs.yoee.net/Uc/home/space.php?uid=52&do=blog&id=438
看看是不是你想要的效果

F. html页面的倒计时代码。。。。急求!!!!

<br>倒计时已结束<br>
<span id="span_dt_dt" style='border:1px solid black;background-color:#FFFFFF' ></span>
<SCRIPT language=javascript>
<!--
//document.write("");
function show_time(){
window.setTimeout("show_time()", 1000);
BirthDay=new Date("00-00-0000");//改成你的计时日期
today=new Date();
timeold=(BirthDay.getTime()-today.getTime());
sectimeold=timeold/1000
secondsold=Math.floor(sectimeold);
msPerDay=24*60*60*1000
e_daysold=timeold/msPerDay
daysold=Math.floor(e_daysold);
e_hrsold=(e_daysold-daysold)*24;
hrsold=Math.floor(e_hrsold);
e_minsold=(e_hrsold-hrsold)*60;
minsold=Math.floor((e_hrsold-hrsold)*60);
seconds=Math.floor((e_minsold-minsold)*60);
span_dt_dt.innerHTML=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒" ;
}
show_time();
//-->
</SCRIPT>
修改成需要的时间段,直接嵌入就可以。

G. 网页弹出个框框源码

最基本的弹出窗口代码】

<SCRIPT LANGUAGE="javascript">
<!--
window.open ('page.html')
-->
</SCRIPT>

因为这是一段javascript代码,所以它们应该放在<SCRIPT LANGUAGE ="javascript">标签和</script>之间。

<!--和-->是对一些版本低的浏览器起作用,在这些老浏览器中如果不支持javascript,不会将标签中的代码作

为文本显示出来。

Window.open ('page.html')用于控制弹出新的窗口page.html,如果page.html不与主窗口在同一路径下,前面

应写明路径,绝对路径(http://)和相对路径(../)均可。
用单引号和双引号都可以,只是不要混用。
这一段代码可以加入HTML的任意位置,加入到<head>和</head>之间也可以,位置越靠前执行越早,尤其是页面

代码较长时,又想使页面早点弹出就尽量往前放。

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

下面再说一说弹出窗口外观的设置。只要再往上面的代码中加一点东西就可以了。
我们来定制这个弹出窗口的外观、尺寸大小、弹出位置以适应该页面的具体情况。

<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>

参数解释:
<SCRIPT LANGUAGE="java script"> js脚本开始;
window.open 弹出新窗口的命令
page.html 弹出新窗口的文件名;
newwindow 弹出窗口的名字(不是文件名),可用空 〃代替;
height=100 窗口高度;
top=0 窗口距离屏幕上方的像素值;
left=0 窗口距离屏幕左侧的像素值;
toolbar=no 是否显示工具栏,yes为显示;
menubar,scrollbars 表示菜单栏和滚动栏;
resizable=no 是否允许改变窗口大小,yes为允许;
location=no 是否显示地址栏,yes为允许;
status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;
</SCRIPT> js脚本结束。

【用函数控制弹出窗口】

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

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

将如下代码加入主窗口<head>区:
<script language="javascript">
<!--
function openwin(){
window.open("page.html","","width=200,height=200";)
}
//-->
</script>

加入<body>区:<a href="1.htm" onclick="openwin()">open</a>即可。

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

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

首先,将如下代码加入page.html文件的<head>区:

<script language="javascript">
function closeit() {
setTimeout("self.close()",10000) //毫秒
}
</script>

然后,再用<body onload="closeit()">这一句话代替page.html中原有的<BODY>这一句就可以了。(这一句话千

万不要忘记写啊!这一句的作用是调用关闭窗口的代码,10秒钟后就自行关闭该窗口。)

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

<form>
<INPUT TYPE='BUTTON' value='关闭' onClick='window.close()'>
</form>
呵呵,现在更加完美了!

【内包含的弹出窗口——一个页面两个窗口】

上面的例子都包含两个窗口,一个是主窗口,另一个是弹出的小窗口。
通过下面的例子,你可以在一个页面内完成上面的效果。

<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="#" onclick="openwin()">打开一个窗口</a>
<input type="button" onclick="openwin()" value="打开窗口">
</body>
</html>

看看OpenWindow.document.write()里面的代码不就是标准的HTML吗?只要按照格式写更多的行即可。千万注意多一个标签或少一个标签都会出现错误。记住用OpenWindow.document.close()结束啊。

【终极应用——弹出窗口的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 returnvalue ="";
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;
returnvalue =unescape(documents.cookie.substring(offset,end))
}
}
return returnvalue;
}
function loadpopup(){
if (get_cookie(’popped’)==";){
openwin()
documents.cookie="popped=yes"
}
}
</script>

然后,用<body onload="loadpopup()">(注意不是openwin 而是loadpop啊)替换主页面中原有的<BODY>这一句即可。你可以试着刷新一下这个页面或重新进入该页面,窗口再也不会弹出了。真正的Pop-Only-Once!
写到这里,弹出窗口的制作和应用技巧基本上算是讲完了,希望对正在制作网页的朋友有所帮助我就非常欣慰了。
需要注意的是,JS脚本中的大小写最好前后保持一致。

没有菜单、工具栏、地址栏的弹出窗口:

<script language="javascript">
<!--
var gt = unescape('%3e');
var popup = null;
var over = "Launch Pop-up Navigator";
popup = window.open('', 'popupnav', 'width=500,height=500,resizable=0,scrollbars=auto'); // width=500,height=500为窗口长和宽
if (popup != null) {
if (popup.opener == null) {
popup.opener = self; }
popup.location.href = '要打开的文件名';
}
// -->
</script>

离开一个页面时弹出一个可定制的窗口

<!-- Begin
function leave() {
window.open(\'离开页面时弹出窗口的URL\',\'\',\'toolbar=no,menubar=no,location=no,height=235,width=320\');
}
// End -->
</script>

如下代码加入HTML的<BODY>区:<body onUnload="leave()">

超级弹窗代码(MYIE也照弹)

<script language="javascript">
focusid=setTimeout("focus();window.showModelessDialog(\'http://www.3tian.com\',\'\',\'scroll:1;status:0;help:0;resizable:1;dialogWidth:0px;dialogHeight:0px\')",0000)
</script>
<script language="javascript">
<!--
function clock(){i=i-1
document.title="";#定义标题
if(i>0)setTimeout("clock();",1000);
else self.close();}
……………………………………
这是很完备的代码了
你可以尝试一下
好运
走先……

H. JS 关于setTimeOut的调用问题

你可以将函数先赋给一个变量
var handler = function(){
//你的代码
setTimeout(handler,20000);//设置20秒调用一次
};
window.onload = handler;
我没看明白你的意思,鼠标移过显示分数为什么要设置20秒调用一次

I. jquery ajax timeout问题.

默认未配置,即不启用超时,需要传递timeout参数来设定超时。

查看jquery的源码:

298行提供了timeout参数

643 判断用户是否传递了timeout>0来决定是否开启超时处理

阅读全文

与settimeout源码相关的资料

热点内容
系统盘被压缩开不了机 浏览:984
linuxredis30 浏览:541
狸窝pdf转换器 浏览:696
ajax调用java后台 浏览:904
活塞式压缩机常见故障 浏览:614
break算法 浏览:731
换电池的app是什么 浏览:771
单片机ad采样快速发送电脑 浏览:22
第五人格服务器错误是什么回事儿 浏览:467
查看手机谷歌服务器地址 浏览:191
python操作zookeeper 浏览:706
苹果手机dcim文件夹显示不出来 浏览:430
如何压缩文件夹联想电脑 浏览:584
程序员的学习之旅 浏览:440
apkdb反编译 浏览:922
雪花算法为什么要二进制 浏览:825
在文档中打开命令行工具 浏览:608
android图标尺寸规范 浏览:369
python实用工具 浏览:210
流量计pdf 浏览:938