随笔 - 12  文章 - 0 评论 - 7 trackbacks - 0
<2012年2月>
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910

昵称:dengwf
园龄:3年8个月
粉丝:1
关注:0

搜索

 
 

常用链接

我的标签

随笔分类

随笔档案

最新评论

阅读排行榜

评论排行榜

推荐排行榜

 

AJAX("POST"
    ,
"/shared/ete2/submitschool.asp"
    ,
"xml="+encodeURIComponent(xml.xml),
    
function(msg){
        
var f=window.document.frames["bgPage"];
        f.document.write(
"<body>"+msg.xml.toString()+"</body>");
        healthCheckNew();
    });


function AJAX(type,url,data,callback){
    
var request = false;
    
try {
        request 
= new XMLHttpRequest();
    } 
catch (trymicrosoft) {
     
try {
        request 
= new ActiveXObject("Msxml2.XMLHTTP");
     } 
catch (othermicrosoft) {
       
try {
            request 
= new ActiveXObject("Microsoft.XMLHTTP");
       } 
catch (failed) {
            request 
= false;
       }  
     }
    }
    
if (!request)    return;
    
    request.open(type, url, 
true);
    request.setRequestHeader(
"CONTENT-TYPE","application/x-www-form-urlencoded");
    request.setRequestHeader(
"Content-Length",data.length);

    request.onreadystatechange 
= function(){
        
if(request.readyState == 4) {
            
if(request.status == 200) {
                callback(request.responseXML);
            } 
         }
    };
    request.send(data);
    
}

 

 

posted @ 2011-02-22 11:57 dengwf 阅读(17) 评论(0) 编辑

<iframe id="ifr" name="ifr" width="100%" height="500" src="bb.html" onload="Init()"></iframe>

 

取Iframe有两种方式:

1.ifr_id = document.getElementById("ifr");  //取到的是dom结果,主要用于操作property,改变Height,width之类的用这个

2.ifr_window = window.frames["ifr"];  //取到的是文档结果,可以取到文档的内容,如ifr_window.document.body.innerHTML

不同的对象用于不同的场合,注意不要弄混。

 

方法互调:

父调子:ifr_window.subMethod();

子调父:parent.topMethod();

注意用到的都是window.frames["ifr"]的方式取到的对象。

 

在Iframe加载完成后再进行操作

如果Iframe还未加载完成就开始调用里面的方法或变量,无疑会产生错误。判断Iframe是否加载完毕有两种方法:

1.在Iframe上用onload事件;

2.用document.readyState=="complete"来判断

 

跨域

并不是所有情况下父页面都可以操作子页面的。哪些情况下允许互相操作呢?

1.两个页面都是处于同一域名下,如www.a.com/

2.两个页面处于同一父域名下,如www.a.com/和bbs.a.com,这种情况默认是不能互访的,但是通过设置document.domain来让其互访,下面会具体讲到。

 

如果父页面在a.com下,引用了一个b.com的Iframe,那么父页面的JS不能读取Iframe的结构,这个问题就是跨域。

为什么要禁止这个操作呢?如果可以随意操作的话,我在自己的站点上引用163的页面,然后读取Iframe的cookie,那么163用户cookie里记住的密码就被收集到了。

 

解决跨域的方法:

1.对于在同一父域名下的,如上面的第二种情况,通过设置document.domain=a.com可让其实现互相访问;

2.对于不在同一父域名下的,但纯用JS是不能实现让其互访的,有一个变通的方法是类似ajax代理,即在a.com下新建一个页面,在server端其访问b.com下面的这个页面,将待访问的这个页面内容输出出来,然后再引用这个新建的页面,就变成在同一域名下了。

 

自适应高度

自适应高度平时用的较多,这里贴一段代码,兼容目前的各种浏览器

代码
<script type="text/javascript" language="javascript">   
    
function iFrameHeight() {   
        
var ifm= document.getElementById("iframepage");   
        
var subWeb = document.frames ? document.frames["iframepage"].document : ifm.contentDocument;   
        
if(ifm != null && subWeb != null) {
           ifm.height 
= subWeb.body.scrollHeight;
        }   
    }   
</script>

 

 

 

 

posted @ 2011-01-06 16:31 dengwf 阅读(300) 评论(1) 编辑

 

Confluence是一个wiki软件,基于Java,以Service的方式在后台提供服务。

 

产品有两个版本,安装版和zip版的。安装版的适合做demo,定制功能弱;winzip版的方便自己配置。

 

以下是Zip安装的步骤以及遇到的一些问题及解决方案:

  1.解压到D:\confluence-3.4.2-std
  2.修改confluence/WEB-INF/classes/confluence-init.properties文件中的路径:confluence.home=d:/confluence/data,这个路径可以自己设置,用来存放wiki运行过程中产生的数据,如用户上传的附件。

  3.修改D:\confluence-3.4.2-std\conf\server.xml,在host子节点里加上<Context path="" docBase="D:/confluence-3.4.2-std/confluence"/>,path是wiki运行的虚拟目录,这里不设。端口也是在这里改的。

  4.在命令行下运行D:\confluence-3.4.2-std\bin\service.bat Install Confluence即可以service的方式注册到系统里运行了。

  5.访问http://localhost/,开始confulence的配置安装,数据库选择jdbc方式:jdbc:jtds:sqlserver://[Server name]:1433/[Db name]。

 

some useful links:

confluence:
http://www.cnblogs.com/badwood316/archive/2009/03/23/1420023.html
http://www.fangwai.net/software/confluence/download/Confluence_Standalone_InstallGuide_v2.pdf

tomcat:
http://wenku.baidu.com/view/f4bc2ed276a20029bd642d38.html

posted @ 2010-11-26 17:04 dengwf 阅读(192) 评论(0) 编辑

层的移动本来很简单,用jquery插件或者自己写一个也不难,但是最近一个ipad项目里,发现用手移动div会感觉很卡,体验很差(可能是ipad的配置根不上pc)。同样如果一个页面结构很复杂或者电脑配置不好的话也会出现这种情况。为了弄清变慢的原因,我们做了几个demo对比,最后发现在mousemove事件上加上定时器能改进这个体验。

 

整个代码的关键地方在于当鼠标按下时开始了的计时器,这样Onmousemove事件会每隔30ms执行一次,然后在鼠标松下的时候清除计时器。

timer=setInterval(function(){flag=true;},30);


这样可以减轻浏览器绘制div层的负担,不至于拖动时每时每刻都在移动,其实太短了人眼也感觉不到变化,延迟间隔可以自己根据体验设置。

 

代码
function Endrag(source,target){
    source
=typeof(source)=="object" ? source:document.getElementById(source);
    target
=typeof(target)=="object" ? target:document.getElementById(target);
    
var x0=0,y0=0,x1=0,y1=0,moveable=false,index=100;
    
var timer,flag=false;
    
var i=0;
    
    source.onmousedown
=function(e){
        e 
= e ? e : (window.event ? window.event : null);
        
                    
        x0 
= e.clientX ; 
        y0 
= e.clientY ; 
        x1 
= isNaN(parseInt(source.style.left))?0:parseInt(source.style.left);
        y1 
= isNaN(parseInt(source.style.top))?0:parseInt(source.style.top);
        moveable 
= true

        
//当鼠标按下时,定时器开始工作,每隔50ms执行一次mousemove事件
        timer=setInterval(function(){flag=true;},30);
         
    }; 
    
//拖动; 
    source.onmousemove=function(e){

        e 
= e ? e : (window.event ? window.event : null); 
        
if(moveable){ 

            
if(flag){
                i
++;
                
                flag
=false;
                target.style.left 
= (e.clientX + x1 - x0 ) + "px"
                target.style.top  
= (e.clientY + y1 - y0 ) + "px"
                
            }
            
        } 
        
    };
    
//停止拖动; 
    source.onmouseup=function (e){
        
if(moveable)  {  
             
            moveable 
= false
            clearInterval(timer);
           
//alert(i);

        } 
    };
    
    
//停止拖动; 
    source.onmouseout=function (e){
        
if(moveable)  {  
            
            moveable 
= false
            clearInterval(timer);
           
//alert(i);

        } 
    };
    
    
}
    

 

 

 

 

 

posted @ 2010-11-16 14:14 dengwf 阅读(153) 评论(1) 编辑

dom结构里,点击子元素后,点击事件会自动向其上层父元素传递,直至document。刚开始看到这个理论觉得很奇怪,后来细想一下,这是必须的。比喻我们在document上绑定了一个事件,我们怎么触发呢,就是在页面上随便位置点一下就行了,那么我们点的这个位置可能是一个div,或者是一个p,如果没有事件传播,dccument就不会触发这个事件了。

 

阻止事件冒泡

什么时候要用到阻止事件冒泡,当页面结构比较复杂时,阻止冒泡可以提高页面性能,如果你只想在当前dom上执行事件的话,没必要让他传递到父层上去。另外在平时用到比较多的popup也会用到这个,弹出一个层div1,当点击除弹出层外的其它位置时,关闭这个popup。如果打算在document上绑定这个close事件时,那就需要在div1上阻止单击事件的冒泡,否则点击了div1也会关闭这个Popup,因为事件会冒泡到document。

IE:

window.event.cancelBubble = true

 

FF:

e.stopPropagation()

 

更多的内容请阅读以下链接:

http://www.blueidea.com/tech/web/2007/4628.asp

http://www.liloy.info/archives/103.html

http://www.liloy.info/archives/131.html

 

posted @ 2010-11-16 10:10 dengwf 阅读(88) 评论(1) 编辑
代码
var Viewport={
        top : function(){
            
return window.pageYOffset
            
|| document.documentElement && document.documentElement.scrollTop
            
|| document.body.scrollTop;
        },
        height : function(){
            
return window.innerHeight
            
|| document.documentElement && document.documentElement.clientHeight
            
|| document.body.clientHeight;
        },
          left : function(){
            
return window.pageXOffset
            
|| document.documentElement && document.documentElement.scrollLeft
            
|| document.body.scrollLeft;
        },
        width : function(){
            
return window.innerWidth
            
|| document.documentElement && document.documentElement.clientWidth
            
|| document.body.clientWidth;
        },
        right : function(){
            
return Viewport.left() + Viewport.width();
        },
        bottom : function(){
            
return Viewport.top() + Viewport.height();
        }
};
 
 
居中:
style.position="absolute";
style.left=50%;
style.top=Viewport.Top()+Viewport.Height()/2+"px";

 

posted @ 2010-05-06 17:36 dengwf 阅读(130) 评论(0) 编辑
摘要: 在项目中有一个需求,要求页面中的checkbox在页面刷新或后退时都要重新初始化,即处于未选中的状态,不保存之前的状态。初一看这个功能很简单,一个checkbox,加一段脚本,把这个checkbox的checked属性设为false。<input type="checkbox" id="chk_UnInital" name="chk_UnInital" /><script>...阅读全文
posted @ 2010-01-17 21:46 dengwf 阅读(220) 评论(0) 编辑
摘要: http://www.cnblogs.com/springxie/archive/2009/04/16/1425942.htmlhttp://blog.csdn.net/yehaiping1214/archive/2008/04/23/2318425.aspxhttp://www.cnblogs.com/HanN1984/archive/2007/05/08/738499.html阅读全文
posted @ 2009-04-29 17:50 dengwf 阅读(8) 评论(0) 编辑
摘要: jquery技巧总结 阅读全文
posted @ 2008-11-13 23:40 dengwf 阅读(57) 评论(0) 编辑
摘要: 在用CSS控制排版过程中,定位一直被人认为是一个难点,这主要是表现为很多网友在没有深入理解清楚定位的原理时,排出来的杂乱网页常让他们不知所措,而另一边一些高手则常常借助定位的强大功能做出些很酷的效果来,比如CSS相册等等,因此自己杂乱的网页与高手完美的设计形成鲜明对比,这在一定程度上打击了初学定位的网友,也在他们心目中形成这样的一种思想:当我熟练地玩转CSS定位时,我就已是高手了。不管你怎么想,我只希望下面的教程能让你更深入地了解CSS定位属性。 阅读全文
posted @ 2008-11-12 22:02 dengwf 阅读(181) 评论(1) 编辑