百度首页 | 百度空间
 
文章列表
 
您正在查看 "javascript&web2.0" 分类下的文章

2007年07月20日 星期五 下午 09:59
在js里面一直没有for each只有for比如这样
var t={x:1,y:2}
for(var x in t)
{
alert(x);
}
会先后打出x和y,而最近mozilla宣布在JavaScript1.6里面加入for each的支持,就是这样
var t={x:1,y:2}
for each(var x in t)
{
alert(x);
}
会先后打出1和2,当然其实for也是可以做到for each的:
var t={x:1,y:2}
for(var x in t)
{
alert(t[x]);
}
虽然是一小进步,但是也是ff优于其他浏览器的一点
关于defer,defer关键字最近遇到,简要说明一下
<scrip
类别:javascript&web2.0 | 评论(0) | 浏览()
 
2007年07月18日 星期三 下午 07:30

<div id="modal_mask" style="display:none;width:100%; height:100%; position:fixed !important;position:absolute;top:0px;left:0px;z-index:90000">
<div style="width:100%; height:100%;position:fixed !important; position:absolute; background-color:#000000; z-index:90000; opacity:0.60;top:0px; left:0px; text-align:center; filter:Alpha(Opacity=60)"><%
if (request.getHeader("User-Agent").indexOf("MSIE 6.0")!=-1)
{
out.println("<iframe scrolling=\"no\" frameborde

类别:javascript&web2.0 | 评论(1) | 浏览()
 
2007年07月17日 星期二 下午 04:49

增加了fixed属性,可以适应滚动情况,以及esc取消,和默认是取消按钮focus,ie6不支持fixed用绝对定位+隐藏scrollbar解决

代码:

<div id="modal_mask" style="display:none;width:100%; height:100%; position:fixed !important;position:absolute;top:0px;left:0px;z-index:90000">
<div style="width:100%; height:100%;position:fixed !important; position:absolute; background-color:#000000; z-index:90000; opacity:0.60;top:0px; left:0px; text-align:center; filter:Alpha(Opacity=60)">

类别:javascript&web2.0 | 评论(0) | 浏览()
 
2007年07月15日 星期日 下午 09:37

ff下面支持对象的__defineGetter__和__defineSetter__方法,可以设置get和set的方法,举例

var t={};

t.__defineGetter__("aaa",function(){alert("haha")});

t.__defineSetter__("aaa",function(tmp){alert("hello"+tmp)});

var e=t.aaa;//执行alert("haha")

t.aaa="world"; //执行alert("hello"+"world")

但是ie下面没有,怎么办,看到了一段代码:

<script type="text/javascript">
Object.prototype.__defineGetter__ = function(attributeName,hanlder)
{

类别:javascript&web2.0 | 评论(0) | 浏览()
 
2007年07月10日 星期二 下午 10:32

var num=0;
function test(){
var t=num;
window.setTimeout(function(){alert(t)},5000);
num++;
}
test();
test();
test();

再加个验证

<script>
var num=0;
var e=5000;
function test(){
var t=num;
window.setTimeout(function(){alert(t)},e);
num++;
e=e-2000;
}
test();
test();
test();
</script>

证明了closure的唯一性

类别:javascript&web2.0 | 评论(0) | 浏览()
 
2007年07月10日 星期二 下午 10:13

<script>
var closure_window="window";
function wrap_1(){
var closure_1="test_1";
function wrap_2(){
   var closure_2="test_2";
   function wrap_3(){
    var closure_3="test_3";
    function wrap_4(){
     var closure_4="test_4";
     outer=function(){alert([closure_window,closure_1,closure_2,closure_3,closure_4])}
    }
 

类别:javascript&web2.0 | 评论(0) | 浏览()
 
2007年07月10日 星期二 下午 04:33
Closure is a thing when you use the keyword "function" in your JavaScript application, when you defines a function, you give it a reference, yes it is a function linked with the window object, and this function can get all the variables in the window and all other objects, but if you defines the function inside a existed function, this inner function first get a hidden reference to the its parent function, I know this look confused, but the js really work like this, and this thing us
类别:javascript&web2.0 | 评论(1) | 浏览()
 
2007年07月08日 星期日 下午 04:37
浏览器性能大测试,测试代码:
<script>
function createEl(i) {
    var span = document.createElement("span");
    span.className = "muci";
    span.innerHTML = " foobar #"+i+" ";
    span.onclick = function() { alert(this.innerHTML + "n" + i); };
    document.body.appendChild(span);
}

function start() {
var T1 =
类别:javascript&web2.0 | 评论(2) | 浏览()
 
2007年07月08日 星期日 下午 03:51
ie6一个臭名昭著的bug就是巨大的内存泄露,比如你使用ie6,打开很多网页,比如10个吧,占用了30m内存,关闭9个吧,可是感觉内存好似没下来。。。。。。。。。只有把最后一个也关闭了,再从新打开,就好多了,这就是内存泄漏,最简单的办法,当然就是关闭进程,再启动了,从起windows好似也是这个意思。。。。。&*()^%$#
好,ie6对于attchEvent上去的handler和一些闭包的原来执行环境的gc回收好似有问题,好似ie开发组说什么为了兼容一些老的程序必须这样泄漏,你最好避免使用闭包,以及attchEvent。。。。。。。我靠。。。。当
类别:javascript&web2.0 | 评论(0) | 浏览()
 
2007年07月08日 星期日 下午 03:10
看一些代码
<div id="testDiv">aaa</div>
<script>
window.onload=function(){
var div = document.getElementById("testDiv");
var events = {onclick: "clicked", onchange: "changed", onmouseover: "mouse over"};

for(e in events){
   div[e] = function(){
     alert(events[e]);
   };
}
};
</script>

<div id="testDiv
类别:javascript&web2.0 | 评论(0) | 浏览()
 
     
 
 
文章分类
 
 
 
 
工作(21)
 
其他(38)
 
Java(1)
 
 
 
Css(1)
 
     
 
文章存档
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
     
 
最新文章评论
   
 

一个学会了批评和自我批评的人.
 

.....上面这位仁兄是who啊?
 
 
 
     


©2008 Baidu