面向对象HTIS

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>new document</title>
    <script type="text/javascript">
        function activeDiv(){
            var div = document.createElement("div"), self = this;
            div.style.cssText = "position:absolute; 300px; height:200px; left:100px;top:100px; border:1px solid #006699; background:#f5f6fb;";
            div.onclick = function(){
                self.drag();
            };
            
            this.element = div;
        }
        activeDiv.prototype.drag = function(){
            alert("drag");
        };
        
        
        window.onload = function(){
            var drag = new activeDiv();
            document.body.appendChild(drag.element);
        };
        
    </script>
</head>
<body>
</body>
</html>
原文地址:https://www.cnblogs.com/yjhua/p/5139409.html