惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
V
Vulnerabilities – Threatpost
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
G
GRAHAM CLULEY
S
Securelist
P
Palo Alto Networks Blog
MongoDB | Blog
MongoDB | Blog
A
Arctic Wolf
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
WordPress大学
WordPress大学
Project Zero
Project Zero
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
C
Cyber Attacks, Cyber Crime and Cyber Security
F
Fortinet All Blogs
博客园 - 叶小钗
B
Blog RSS Feed
C
Cisco Blogs
Google DeepMind News
Google DeepMind News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
G
Google Developers Blog
K
Kaspersky official blog
D
Docker
Latest news
Latest news
Cisco Talos Blog
Cisco Talos Blog
T
Tor Project blog
Cyberwarzone
Cyberwarzone
Security Latest
Security Latest
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
C
Check Point Blog
J
Java Code Geeks
Simon Willison's Weblog
Simon Willison's Weblog
T
Tenable Blog
Recent Announcements
Recent Announcements
T
Tailwind CSS Blog
H
Help Net Security
L
LINUX DO - 热门话题
T
The Exploit Database - CXSecurity.com
Jina AI
Jina AI
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
NISL@THU
NISL@THU
美团技术团队
腾讯CDC

博客园 - Kent

55种网页常用小技巧 - Kent - 博客园 (转文)IP Domain etc. CodeFile、Src、Codebehind三者的差别解释 - Kent - 博客园 Microsoft SQL Server 2005的国际功能(转贴) SQL Server 中易混淆的数据类型 关于 SQL Server 使用 Unicode 数据 Sys.WebForms.PageRequestManagerParserErrorException 错误的解决办法 SQLserver2005中的四个评价函数 常用DOS命令(转贴) 类的一般标准写法 正则表达式(regular expression) C#: 为datatable添加column的方法 C#: 三种符号的区别 C#:List 取代数组的方法 javascript:parseFloat javascript:trim function javascript: split & array javascript:eval function Javascript: Replace function.
javascript setTimeout 和 setInterval
Kent · 2007-09-21 · via 博客园 - Kent

下面这一段代码是我下面的一个SP写的javascript.
这一段代码会耗尽客户端的资源!直接死机!

setTimeout] setTimeout(表达式,延时时间)

在执行时,是在载入后延迟指定时间后,去执行一次表达式,记住,次数是一次

用setTimeout实现的自动变化显示随机数的效果:

<html> <head> <script> window.onload=sett; function sett() { document.body.innerHTML=Math.random(); setTimeout("sett()",500); } </script> </head> <body> </body> </html>

[setInterval] setInterval(表达式,交互时间)

则不一样,它从载入后,每隔指定的时间就执行一次表达式

用setInterval实现的自动变化显示随机数的效果: <html> <head> <script> function sett() { document.body.innerHTML=Math.random(); } setInterval("sett();", 500); </script> </script> </head> <body> </body> </html>

解决方法:我初定的方案是用setInterval来实现相应的操作。
其实,这一个函数的最终目的是要生成一个浮动的按钮。
而且20毫秒实在太短!
Hope to solve it tomorrow!

/***************************************************
* float move
***************************************************/
function F_FloatBar_move(objId,align,valign,xControl,yControl,hasParent)
{
     var objDiv=document.getElementById(objId);
     if(objDiv==null)
     {
       return;
     }
     var FloatBar_Top = F_AdjustFloatTopPx(valign,F_GetClientHeight(hasParent),hasParent);
     var FloatBar_Left=F_AdjustFloatLeftPx(align,F_GetClientWidth(hasParent),hasParent);
     var FloatBar_Delta = 0.05;
  
     var scrollTop=document.documentElement.scrollTop;
     var scrollLeft=document.documentElement.scrollLeft;
     if(hasParent=="true")
     {
        scrollTop=window.parent.document.documentElement.scrollTop;
        scrollLeft=window.parent.document.documentElement.scrollLeft;
     }
     if(yControl!="")
     {
        objDiv.style.top=F_GetOffsetTop(objId,valign,yControl)+"px";
     }
     else
     {
         if(objDiv.offsetTop != (scrollTop + FloatBar_Top))
           {
               var dy = (scrollTop + FloatBar_Top - objDiv.offsetTop) * FloatBar_Delta;
               dy = (dy > 0 ? 1 :  - 1) * Math.ceil(Math.abs(dy));
               objDiv.style.top = F_GetTopPx(objId,(objDiv.offsetTop + dy),F_GetClientHeight("false"))+"px";
           }
       }
      if(xControl!="")
       {
        objDiv.style.left=F_GetOffsetLeft(objId,align,xControl)+"px";
       }
       else
       {
          if(objDiv.offsetLeft != (scrollLeft + FloatBar_Left))
           {
               var dx = (scrollLeft + FloatBar_Left - objDiv.offsetLeft) * FloatBar_Delta;
             
               dx = (dx > 0 ? 1 :  - 1) * Math.ceil(Math.abs(dx));
               if((objDiv.offsetLeft + dx)>=0)
               {
               objDiv.style.left = F_GetLeftPx(objId,(objDiv.offsetLeft + dx),F_GetClientWidth("false"))+"px";
               }
           }
        }
     setTimeout("F_FloatBar_move('"+objId+"','"+align+"','"+valign+"','"+xControl+"','"+yControl+"','"+hasParent+"')",20);
}