js實現展開拖動iframe

來源:互聯網
上載者:User

 左邊iframe放樹目錄,右邊的iframe放index頁。拖滑鼠同時控制2個iframe的寬高。

期待有人能改進。

操作方法:滑鼠指到2個iframe中間,可以水平拖,縱向拖(控制高度)

缺點:CSDN頁面放開滑鼠後才改大小,不佔CPU資源。 這個是即時改大小,所以速度太慢,希望有人來改改。我是不想弄了,反正又沒用什麼特別的技術。

提示:拖動的秘密就在filter:alpha(opacity=0)這一句


<html>
<script language="javascript"> 
var mouseX = 0; 
var mouseY = 0;
var w=5; 
function divonmousemove(){ 
obj1=document.getElementById("a");
obj2=document.getElementById("b");
obj12=document.getElementById("ab");
if (mouseX!==event.x && mouseY!==event.y)obj12.style.cursor='se-resize'; 
else if (mouseX!==event.x)obj12.style.cursor='e-resize'; 
else if (mouseY!==event.y)obj12.style.cursor='s-resize'; 
else obj12.style.cursor=''; 
if (event.button==1){ 
obj1.style.width=parseInt(obj1.offsetWidth)+(event.x - mouseX); 
mouseX=event.x;
obj1.style.height=parseInt(obj1.offsetHeight)+(event.y - mouseY); 
mouseY= event.y; 
obj12.style.width=108;
obj12.style.left=obj1.offsetWidth-obj12.offsetWidth/2;
obj12.style.height=obj1.clientHeight;
obj2.style.height=obj1.clientHeight;
obj2.style.left=obj1.clientWidth+w;
obj2.style.width=screen.width-obj1.offsetWidth-w;
}} 

function divonmousedown(){ 
mouseX = event.x; 
mouseY = event.y;


function divonmouseup(){ 
obj12.style.left=obj1.offsetWidth;
obj12.style.width=w;
mouseX = 0; 
mouseY = 0;} 
</script> 
<body style='margin:0'>
<iframe zindex=1 id="a" src="http://community.csdn.net/Tree/tree.htm" style="width:200;height:610;position:absolute;z-index:9 "></iframe>
<div zindex=0 id='ab' onmousemove='divonmousemove();' onmouseleave='document.getElementById("ab").style.cursor='';' 
>
< table style="width:100%;height:100%;" border=0 cellspacing=0 cellpadding=0px >
< tr>
< td style="width:150px;" >
< iframe zindex=1 id="a" src="http://community.csdn.net/Tree/tree.htm" style="width:100%;height:100%;z-index:9 "></iframe>
< /td>
< td style="width:3px;cursor:e-resize;background-color:#cccccc;" align="center" valign="middle"
onmousedown="Resize_mousedown(event,this);" onmouseup="Resize_mouseup(event,this);" onmousemove="Resize_mousemove(event,this);">
<font style="size:3px;background-color:#eeeeee;cursor:pointer;" onmousedown="Resize_setDefault(event,this);"><</font>
< /td>
< td>
< iframe zindex=1 id="b" name="ContentFrame" src="http://community.csdn.net/index.htm" style="width:100%;height:100%;z-index:10"></iframe>
< /td>
< /tr>
< /table>
< /body> 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.