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

推荐订阅源

美团技术团队
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
IT之家
IT之家
月光博客
月光博客
U
Unit 42
K
Kaspersky official blog
T
Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Engineering at Meta
Engineering at Meta
Recorded Future
Recorded Future
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog
P
Palo Alto Networks Blog
爱范儿
爱范儿
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 热门话题
C
Cisco Blogs
Spread Privacy
Spread Privacy
F
Full Disclosure
博客园 - 聂微东
T
The Blog of Author Tim Ferriss

博客园 - hone

管理 java学习 服务器相关 总统和亿万富翁经典语录(转载) 最近学习计划 VC控制Excel 真乱(转自csdn) 沟通(网上搜集) 工作 无题 将文档发送到打印机(From MSN) 经典68个故事 Manually Invalidating All Stale Sessions java的zip压缩(转自Jeet) 图形相关 在Oracle9i中计算时间差 六度分隔 经典故事 新年竟然第一篇?!
js学习笔记
hone · 2007-01-23 · via 博客园 - hone

1.匿名函数

2.定义函数之后就可以立即使用它

1function(x,y,z) return (x+y+z) } ) (123);
2

可以在括号中编写函数表达式,然后传递给参数,对参数进行运算。
3.将函数作为参数传递,并应用该函数:

1var passFunAndApply = function (fn,x,y,z) return fn(x,y,z); };
2
3var sum = function(x,y,z) {
4  return x+y+z;
5}
;
6
7alert( passFunAndApply(sum,3,4,5) ); // 12

执行最后一个 alert 语句输出了一个大小为 12 的值。

JavaScript 中的函数式风格作一快速总结:

  • 函数并不总是需要名称。
  • 函数可以像其他值一样分配给变量。
  • 函数表达式可以编写并放在括号中,留待以后应用。
  • 函数可以作为参数传递给其他函数。

4.在回调中调用一组函数

1window.setTimeout(function(){alert(‘First!’);alert(‘Second!’);}5000);

5.调用系列函数的更好的方式

 1 Function.prototype.sequence=function(g) {
 2   var f=this;
 3   return function() {
 4     f();g();
 5   }
 6 };
 7 function alertFrst() { alert(‘First!’); }
 8 function alertSec() { alert(‘Second!’); }
 9 setTimeout( alertFrst.sequence(alertSec), 5000);
10 

6.打印html

// creates an invisible iframe, puts the original source code inside and prints it
PrintSource = function(sender)
{
    
var td        = sender.parentNode;
    
var code    = td.processedCode;
    
var iframe    = document.createElement('IFRAME');
    
var doc        = null;
    
var wnd        = 

    
// this hides the iframe
    iframe.style.cssText = 'position:absolute; width:0px; height:0px; left:-5px; top:-5px;';
    
    td.appendChild(iframe);
    
    doc 
= iframe.contentWindow.document;
    code 
= code.replace(/</g, '&lt;');
    
    doc.open();
    doc.write('
<pre>+ code + '</pre>');
    doc.close();
    
    iframe.contentWindow.focus();
    iframe.contentWindow.print();
    
    td.removeChild(iframe);
}

//自带的打印预览 

WebBrowser.ExecWB(
1,1) 打开  
Web.ExecWB(
2,1) 关闭现在所有的IE窗口,并打开一个新窗口  
Web.ExecWB(
4,1) 保存网页  
Web.ExecWB(
6,1) 打印  
Web.ExecWB(
7,1) 打印预览  
Web.ExecWB(
8,1) 打印页面设置  
Web.ExecWB(
10,1) 查看页面属性  
Web.ExecWB(
15,1) 好像是撤销,有待确认  
Web.ExecWB(
17,1) 全选  
Web.ExecWB(
22,1) 刷新  
Web.ExecWB(
45,1) 关闭窗体无提示  
<style media=print>  
.Noprint{display:none;}
<!--用本样式在打印时隐藏非打印项目-->  
.PageNext{page
-break-after: always;}<!--控制分页-->  
</style>  
<object  id="WebBrowser"  width=0  height=0  classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">     
</object>     
  
<center class="Noprint" > 
<input type=button value=打印 onclick=document.all.WebBrowser.ExecWB(6,1)>  
<input type=button value=直接打印 onclick=document.all.WebBrowser.ExecWB(6,6)>  
<input type=button value=页面设置 onclick=document.all.WebBrowser.ExecWB(8,1)>  
</p>  
<p> <input type=button value=打印预览 onclick=document.all.WebBrowser.ExecWB(7,1)>  
</center> 
//去掉打印时的页眉页脚 

 
<script  language="JavaScript">   
var HKEY_Root,HKEY_Path,HKEY_Key; 
HKEY_Root
="HKEY_CURRENT_USER"
HKEY_Path
="\Software\Microsoft\Internet Explorer\PageSetup\"
//设置网页打印的页眉页脚为空 
function PageSetup_Null() 

 
try 
 { 
         
var Wsh=new ActiveXObject("WScript.Shell"); 
  HKEY_Key
="header"
  Wsh.RegWrite(HKEY_Root
+HKEY_Path+HKEY_Key,""); 
  HKEY_Key
="footer"
  Wsh.RegWrite(HKEY_Root
+HKEY_Path+HKEY_Key,""); 
 } 
 
catch(e){} 

//设置网页打印的页眉页脚为默认值 
function  PageSetup_Default() 
{   
 
try 
 { 
  
var Wsh=new ActiveXObject("WScript.Shell"); 
  HKEY_Key
="header"
  Wsh.RegWrite(HKEY_Root
+HKEY_Path+HKEY_Key,"&w&b页码,&p/&P"); 
  HKEY_Key
="footer"
  Wsh.RegWrite(HKEY_Root
+HKEY_Path+HKEY_Key,"&u&b&d"); 
 } 
 
catch(e){} 

</script> 
<input type="button" value="清空页码" onclick=PageSetup_Null()> 
<input type="button" value="恢复页码" onclick=PageSetup_Default()>