麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > JavaScript > 正文

js實現拉伸拖動iframe的具體代碼

2019-11-20 22:27:34
字體:
來源:轉載
供稿:網友
左邊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://www.companysz.com/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='';'
 onmousedown='divonmousedown();' onmouseup='divonmouseup();'
 style='filter:alpha(opacity=0);width:5;height:799;background:#aaffaa;position:absolute;left:200;z-index:100' title='按下鼠標拖動大小'></div> 
 <iframe zindex=1 id="b" name="ContentFrame" src="http://www.companysz.com/index.htm" style="width:799;height:612;position:absolute;left:205;z-index:10"></iframe>
 </body>
  </html>

修改一:
復制代碼 代碼如下:

<script language="javascript">
var isResizing=false;
function Resize_mousedown(event,obj){
obj.mouseDownX=event.clientX;
obj.leftTdW=obj.previousSibling.offsetWidth;
obj.setCapture();
isResizing=true;
}
function Resize_mousemove(event,obj){
if(!isResizing) return ;
var newWidth=obj.leftTdW*1+event.clientX*1-obj.mouseDownX;
if(newWidth>0) obj.previousSibling.style.width = newWidth;
else obj.previousSibling.style.width=1;
}
function Resize_mouseup(event,obj){
if(!isResizing) return;
obj.releaseCapture();
isResizing=false;
}
< /script>
< body style='margin:0' >
< table style="width:100%;height:100%;" border=0 cellspacing=0 cellpadding=0px >
< tr>
< td style="width:150px;">
< iframe zindex=1 id="a" src="http://www.companysz.com/Tree/tree.htm" style="width:100%;height:100%;z-index:9 "></iframe>
< /td>
< td style="width:2px;cursor:e-resize;background-color:#cccccc;" onmousedown="Resize_mousedown(event,this);"
onmouseup="Resize_mouseup(event,this);" onmousemove="Resize_mousemove(event,this);">
< /td>
< td>
< iframe zindex=1 id="b" name="ContentFrame" src="http://www.companysz.com/index.htm" style="width:100%;height:100%;z-index:10"></iframe>
< /td>
< /tr>
< /table>
< /body>

修改二:
復制代碼 代碼如下:

<script language="javascript">
var isResizing=false;
function Resize_mousedown(event,obj){
obj.mouseDownX=event.clientX;
obj.leftTdW=obj.previousSibling.offsetWidth;
obj.setCapture();
isResizing=true;
}
function Resize_mousemove(event,obj){
if(!isResizing) return ;
var newWidth=obj.leftTdW*1+event.clientX*1-obj.mouseDownX;
if(newWidth>0) obj.previousSibling.style.width = newWidth;
else obj.previousSibling.style.width=1;
}
function Resize_mouseup(event,obj){
if(!isResizing) return;
obj.releaseCapture();
isResizing=false;
}
function Resize_setDefault(event,obj){
if(obj.innerText=="<") {
obj.parentNode.previousSibling.style.width=1;
obj.innerText=">";
}
else{
obj.parentNode.previousSibling.style.width=150;
obj.innerText="<";
}
event.cancelBubble=true;
}
< /script>
< body style='margin:0' >
< table style="width:100%;height:100%;" border=0 cellspacing=0 cellpadding=0px >
< tr>
< td style="width:150px;" >
< iframe zindex=1 id="a" src="http://www.companysz.com/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://www.companysz.com/index.htm" style="width:100%;height:100%;z-index:10"></iframe>
< /td>
< /tr>
< /table>
< /body>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 手机国产乱子伦精品视频 | 神马顶级推理片免费看 | av在线更新 | 久久国产一级片 | 夜夜看 | 亚洲成人黄色片 | 最新中文字幕第一页视频 | chinese中国真实乱对白 | 黄色av网站免费看 | av电影网站在线 | 美女在线观看视频一区二区 | 狠狠干91| 懂色粉嫩av久婷啪 | 欧美黄一区 | 一级精品| 国产精品视频中文字幕 | 久久亚洲精品久久国产一区二区 | 视屏一区 | 国产免费小视频在线观看 | 懂色av懂色aⅴ精彩av | 国产在线观看91精品 | 免费一区二区三区 | 国产免费久久久久 | 3xxx | 中文字幕综合在线观看 | 成人做爰高潮片免费视频韩国 | 91精品国产刺激国语对白 | 91美女视频在线 | 中文字幕在线观看1 | 一区二区三高清 | 欧美黑大粗硬毛片视频 | 369看片你懂的小视频在线观看 | av一道本 | 欧洲成人综合网 | 黄色大片大毛片 | 国产亚洲精品综合一区91555 | 美女视频大全网站免费 | 日韩精品久久久久久久电影99爱 | 久久艹逼| 免费激情网址 | 56av国产精品久久久久久久 |