http://community.csdn.net/Expert/TopicView1.asp?id=3810715
现成的你不用?

解决方案 »

  1.   

    好郁闷,有vml大虾吗?怎么取得页面中的矩形?像以前,引进的图片只要取得图片标签即img就能得到图片,可是vml画的矩形是以v:rect开头的,取标签v:rect时出错,不能这样取,怎么办?有开发过vml的吗?
      

  2.   

    <HTML xmlns:v>
    <head>
    <STYLE>v\:*{behavior:url(#default#VML);
    t:expression(this.ondragstart=function(){startDrag(this)});
    e:expression(this.ondragend=function(){endDrag(this)});
    }
    < !--
    .skin0 {
    position:absolute;
    text-align:left;
    width:200px;
    border:2px solid black;
    background-color:menu;
    font-family:Verdana;
    line-height:20px;
    cursor:default;
    visibility:hidden;
    }
    .skin1 {
    cursor:default;
    font:menutext;
    position:absolute;
    text-align:left;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10pt;
    width:120px;
    background-color:menu;
    border:1 solid buttonface;
    visibility:hidden;
    border:2 outset buttonhighlight;
    }
    .menuitems {
    padding-left:15px;
    padding-right:10px;
    }
    --></STYLE>
    <SCRIPT language="javascript">
    var start_x=0;
    var start_y=0;
    var end_x=0;
    var end_y=0;function startDrag(obj)
    {
      start_x=obj.currentStyle.left;
      start_y=obj.currentStyle.top;
    }function endDrag(obj)
    {
      end_x=event.clientX;
      end_y=event.clientY;
      obj.style.left=(parseInt(obj.currentStyle.left)+end_x-parseInt(start_x)).toString()+'px';
      obj.style.top=(parseInt(obj.currentStyle.top)+end_y-parseInt(start_y)).toString()+'px';
    }
    function MouseOver()
    {  
      Obj=event.srcElement;
      Obj.runtimeStyle.cursor = "hand";
      Obj.style.color="black";
    }
    function move()
    {if(obj!=null)
    {
    obj.style.left=event.x-x;
    obj.style.top=event.y-y;
    }event.returnValue=false;
    }
    function up()
    {
     if(obj!=null){
    obj.releaseCapture();

    obj=null;

    }
     }
    function MouseOut()
    {
    Obj.runtimeStyle.cursor="default";
       Obj=null;
    } var menuskin = "skin1"; // skin0, or skin1
    var display_url = 0; // Show URLs in status bar?
    function showmenuie5() {
    var rightedge = document.body.clientWidth-event.clientX;
    var bottomedge = document.body.clientHeight-event.clientY;
    ie5menu.style.zIndex=10000;
    if (rightedge < ie5menu.offsetWidth)
    ie5menu.style.left = document.body.scrollLeft + event.clientX -
    ie5menu.offsetWidth;
    else
    ie5menu.style.left = document.body.scrollLeft + event.clientX;
    if (bottomedge < ie5menu.offsetHeight)
    ie5menu.style.top = document.body.scrollTop + event.clientY -
    ie5menu.offsetHeight;
    else
    ie5menu.style.top = document.body.scrollTop + event.clientY;
    ie5menu.style.visibility = "visible";
    return false;
    }
    function hidemenuie5() {
    ie5menu.style.visibility = "hidden";
    }
    function highlightie5() {
    if (event.srcElement.className == "menuitems") {
    event.srcElement.style.backgroundColor = "highlight";
    event.srcElement.style.color = "white";
    if (display_url)
    window.status = event.srcElement.url;
    }
    }
    function lowlightie5() {
    if (event.srcElement.className == "menuitems") {
    event.srcElement.style.backgroundColor = "";
    event.srcElement.style.color = "black";
    window.status = "";
    }
    }
    function jumptoie5() {
    if (event.srcElement.className == "menuitems") {
    if (event.srcElement.getAttribute("target") != null)
    window.open(event.srcElement.url, event.srcElement.getAttribute("target"));
    else
    window.location = event.srcElement.url;
    }
    }
    </SCRIPT>
    <div id="ie5menu" class="skin0" onMouseover="highlightie5()"
    onMouseout="lowlightie5()"   onClick="jumptoie5()" Z-INDEX:10000>
    <div class="menuitems" url="javascript:history.back();"><a href="#" onclick="history.back()">返回</div><hr>
    <div class="menuitems" url="http://www.163.com"><a target="_blank" href="http://www.163.com">网易</a></div>
    <div class="menuitems" url="http://www.sohu.com"><a target="_blank" href="http://www.sohu.com">搜狐</a></div>
    <hr>
    <div class="menuitems" url="http://www.sina.com.cn"><a target="_blank" href="http://www.sina.com.cn">新浪</a></div>
    <div class="menuitems" url="http://www.yahoo.com.cn"><a target="_blank" href="http://www.yahoo.com.cn">雅虎</a></div>
    </div>
    <script language="JavaScript1.2">
    if (document.all && window.print) {
    ie5menu.className = menuskin;document.body.onclick = hidemenuie5;
    }</script></head>
    <BODY>
    <DIV>
    <v:rect id=vml1 style="Z-INDEX:3003;LEFT:418;WIDTH:67;POSITION:absolute;TOP:207;HEIGHT:60" fillcolor="red" strokecolor="green" strokeweight="2px" onmouseover="MouseOver();fillcolor='blue'" onmouseout="fillcolor='red'" oncontextmenu="showmenuie5();return false" />
    </DIV>
    <DIV>
    <v:rect id=vml2 style="Z-INDEX:3003;LEFT:621;WIDTH:67;POSITION:absolute;TOP:378;HEIGHT:60" fillcolor="red" strokecolor="green" strokeweight="2px" onmouseover="MouseOver();fillcolor='blue'" onmouseout="fillcolor='red'" oncontextmenu="showmenuie5();return false"/>
    </DIV>
    <DIV>
    <v:rect id=vml3 style="Z-INDEX:3003;LEFT:791;WIDTH:67;POSITION:absolute;TOP:205;HEIGHT:60" fillcolor="red" strokecolor="green" strokeweight="2px" onmouseover="MouseOver();fillcolor='blue'" onmouseout="fillcolor='red'" oncontextmenu="showmenuie5();return false"/>
    </DIV>
    <DIV id='div4'><v:line id=vml5 style="Z-INDEX:3014;LEFT:503;POSITION:absolute;TOP:237" from="0,0" to="275,0" strokecolor="green" strokeweight="2px" onmouseover="MouseOver();strokecolor='black'" onmouseout="strokecolor='green'" title="网元间关系"/>
    </div>
    <DIV id='div5'><v:line id=vml6 style="Z-INDEX:3015;LEFT:820;POSITION:absolute;TOP:281" from="0,0" to="-125,125" strokecolor="green" strokeweight="2px" onmouseover="MouseOver()" title="网元间关系"/>
    </div>
    <DIV id='div6'><v:line id=vml7 style="Z-INDEX:3016;LEFT:454;POSITION:absolute;TOP:282" from="0,0" to="160,125" strokecolor="green" strokeweight="2px" onmouseover="MouseOver()" title="网元间关系"/>
    </div>
    </body></HTML>
    效果不尽如人意,老板需要的是随时都跟随鼠标的那种拖动,有高手吗?快来拿分,帮帮忙。
      

  3.   

    拖动这个,我前两天开发的时候也试了一下,发现不行!不支持拖动,onDrag这个事件不支持,查了一下参考,onDrag是属于编辑事件,可能跟这个有关!如果支持,那就没什么问题了!