Javascript学习笔记之作用域
在Javascript中作用域是由函数划分的。
//设置全局变量foo
var foo = "test";
if(true){
var foo = "new foo";
}
//此时foo为"new test"
alert(foo == "new foo");
function test(){
var foo = "old test";
}
//调用时,foo只在函数作用域内起作用
test();
//foo还是等于"new test"
alert(foo == "new test");
基于Javascript的一个特性是,所有基于全局作用域的变量都是window对象的属性。
var test = "test";
alert(window.test == test);
当省略var时,变量默认为全局的,即便是在函数内部出现。
function test(){
foo = "test";
}
test();
alert(window.foo == "test");
相关文档:
JavaScript
转自: http://www.disandu.com/?p=603
============================================================================
1 处理XSLT 调用带参数的XSLT模板的方法 详见 23条
<html>
<body>
  ......
在地址栏输入:
javascript:str='';for%20(var1=0;var1<document.images.length;var1++){str+='\n'+document.images[var1].src};if(str!=''){document.write(str);void(document.close())}else{alert('No%20images!')}
然后查看新出来的页面的源代码
若要显示出来,则:
javascript:funcname='';for%20(var1=0;var ......
用JavaScript修改网页样式
一、局部改变样式
分为改变直接样式,改变className和改变cssText三种。需要注意的是:
注意大小写
:
javascript对大小写十分敏感,className不能够把“N”写成“n”,cssText也不能够把“T”写成“t”,否则无法实现效果。
调用方法
:
如果改 ......
本文来自http://q.yesky.com/group/review-17634017.html,另外还添加一些里面技术的链接。
离线事件(Online and offline events):
https://developer.mozilla.org/En/Online_and_offline_events
https://bug336359.bugzilla.mozilla.org/attachment.cgi?id=220609
http://ejohn.org/blog/offline-events/
postMessage ......
在开发过程中经常遇到要调整小数的格式,如保留小数点后两位等等。方法也颇为常见,备忘如下。
第一种,利用math.round
var original=28.453
1) //round "original" to two decimals
var result=Math.round(original*100)/100; //returns 28.45
2) // round "original" to 1 dec ......