Posted on 2007. 12. 12. 10:30
Filed Under 카테고리 없음

<html>
<head>
<script type="text/javascript">
  function myinit() {
    var ancs=document.all.tags("a");
    var imgs=document.all.tags("img");
    for (var i=0; i<ancs.length; i++) ancs[i].ondragend=function(){mydrop()};
    for (var i=0; i<imgs.length; i++) imgs[i].ondragend=function(){mydrop()};
  }
  function mydrop() {
    if (getPosition(document.all.myarea)) {
      alert(getUrl(event.srcElement));
    } else if (getPosition(document.all.myframe)) {
      document.all.myframe.src=getUrl(event.srcElement);
    }
  }
  function getPosition(obj) {
    var a=obj.getBoundingClientRect();
    return event.x>a.left&&event.x<a.right&&event.y>a.top&&event.y<a.bottom;
  }
  function getUrl(obj) {
    var result;
    if (obj.tagName=="A") {
      result=obj.href;
    } else if (obj.tagName=="IMG") {
      result=obj.src;
    } else result=null;
    return result;
  }
</script>
</head>
<body onload="myinit()">
  <div id=myarea style="border:inset 2;width:300;height:100;"></div>
  <iframe id=myframe src="about:blank" width=300 height=100></iframe>
  <br><a href="
http://www.naver.com/">naver</a>
  <br><a href="
http://kin.naver.com/">kin</a>
  <br><img src="
http://static.naver.com/kin/img/kin_logo4.gif">
  <br><img src="
http://wstatic.naver.com/w/n_c600.gif">
</body>
</html>

About

by 청지인

Notice

Counter

· Total
:
· Today
:
· Yesterday
: