扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:朱先忠编译 来源:天极软件 2007年11月6日
关键字: Windows
<script type="text/javascript"> function addFloatingBehavior(ctrl, ctrlHandle){ //创建新的漂浮行为对象 var floatingBehavior = new Sys.UI.FloatingBehavior(); //漂浮行为类具有一个Handle属性 floatingBehavior.set_handle(ctrlHandle); //把对象参考值的为Atlas客户端控件 var dragItem = new Sys.UI.Control(ctrl); //从Atlas控件中取得行为集合 //添加我们自己的漂浮行为 dragItem.get_behaviors().add(floatingBehavior); //运行该漂浮行为的内部javascript floatingBehavior.initialize(); } </script> |
<script type="text/javascript"> function pageLoad(){ addFloatingBehavior(document.getElementById('draggableDiv'),document.getElementById('handleBar')); } </script> |
<script type="text/javascript"> function pageLoad(){ addFloatingBehavior($('draggableDiv'),$('handleBar')); } </script> |
function createDraggableDiv() { var panel= document.createElement("div"); panel.style.height="100px"; panel.style.width="100px"; panel.style.backgroundColor="Blue"; var panelHandle = document.createElement("div"); panelHandle.style.height="20px"; panelHandle.style.width="auto"; panelHandle.style.backgroundColor="Green"; panel.appendChild(panelHandle); var target = $('containerDiv').appendChild(panel); addFloatingBehavior(panel, panelHandle); } |
<input type="button" value="Add Floating Div" onclick="createDraggableDiv();" /> <div id="containerDiv" style="background-color:Purple;height:800px;width:600px;"/> |
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Imperative Drag and Drop II</title> <script type="text/javascript"> function createDraggableDiv() { var panel= document.createElement("div"); panel.style.height="100px"; panel.style.width="100px"; panel.style.backgroundColor="Blue"; var panelHandle = document.createElement("div"); panelHandle.style.height="20px"; panelHandle.style.width="auto"; panelHandle.style.backgroundColor="Green"; panel.appendChild(panelHandle); var target = $('containerDiv').appendChild(panel); addFloatingBehavior(panel, panelHandle); } function addFloatingBehavior(ctrl, ctrlHandle){ var floatingBehavior = new Sys.UI.FloatingBehavior(); floatingBehavior.set_handle(ctrlHandle); var dragItem = new Sys.UI.Control(ctrl); dragItem.get_behaviors().add(floatingBehavior); floatingBehavior.initialize(); } </script> </head> <body> <form id="form1" runat="server"> <atlas:ScriptManager ID="ScriptManager1" runat="server"> <Scripts> <atlas:ScriptReference ScriptName="AtlasUIDragDrop" /> </Scripts> </atlas:ScriptManager> <h2>Imperative Drag and Drop Code with javascript: demonstrate dynamic loading of behaviors</h2> <input type="button" value="Add Floating Div" onclick="createDraggableDiv();" /> <div id="containerDiv" style="background-color:Purple;height:800px;width:600px;"/> </form> </body> </html> |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者