IE中通过setCapture监听鼠标按下和移动,Chrome浏览器中没有相应的方法,所以通过其它方式来实现。
兼容IE和Chrome的拖动改变布局宽度
function startResize(){
if(resizeBox.setCapture){ resizeBox.setCapture(); resizeBox.οnmοusemοve=function(e){ var w=(e||event).x-6; if(w<0) w=0; document.all("left").style.width=w; } resizeBox.οnmοuseup=function(){ resizeBox.releaseCapture(); leftWidth=document.all("left").style.pixelWidth; resizeBox.οnmοusemοve=null; resizeBox.οnmοuseup=null; } }else{ var oLeft = get("left"),oMain =get("main"),oMainTd =get("mainTd");
var oWrapperDiv=ge("wrapperDiv");
swidth = document.body.clientWidth;
sheight = document.body.clientHeight;document.οnmοusemοve=function(e){
if(oWrapperDiv.style.display=="none"){
oWrapperDiv.style.width=swidth; oWrapperDiv.style.height=sheight; oWrapperDiv.style.display=""; }var w=(e||event).screenX-6;
if(w<0) w=0; //oLine.style.left =w+ "px"; //oMain.style.left = w + "px"; oLeft.style.width=w+ "px"; oMain.style.width=(oMain.style.width-w)+ "px"; //oMainTd.style.width=(oMainTd.style.width-w)+ "px"; return false } document.οnmοuseup=function(){oWrapperDiv.style.display="none";
leftWidth=document.all("left").style.pixelWidth;
document. = null; document. = null; } } } |
<!-- a.html内容-->
a left
dd
<!-- b.html内容-->
注:wrapperDiv的处理是为了一360极速浏览器的兼容模式等的情况