A javascript selector
来源:互联网 发布:互联网金融 大数据 编辑:程序博客网 时间:2024/04/30 04:58
This is a selector,but there is a problem that it will show an error when you click the body quickly in IE. it's done in FF.i will modifiy it at spare time. If you have some advice,please let me know.
Thanks
Thanks
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <html>
- <head>
- <title>^_^-Stefli's Selector</title>
- <style type="text/css">
- body {
- margin: 0px;
- padding: 0px;
- }
- #layer {
- position:absolute;
- background:#efefef;
- width:400px;
- height:400px;
- top:0p;
- left:0px;
- }
- </style>
- </head>
- <body>
- <div id="layer"></div>
- <script type="text/javascript">
- var drag;
- function Class() {
- this.id = 1;
- this.x;
- this.y;
- this.obj;
- eval(this.obj + "=this");
- this.initial = function() {
- this.obj = document.createElement("DIV");
- $("layer").appendChild(this.obj);
- with(this.obj) {
- id = this.id;
- this.obj.style.position = "absolute";
- this.obj.style.border = "1px solid #00f";
- this.obj.style.lineHeight = "0px";
- this.obj.style.display = "none";
- thisthis.id = this.id + 1;
- }
- }
- this.move = function(x, y) {
- this.x = x;
- this.y = y;
- this.obj.style.left = x;
- this.obj.style.top = y;
- }
- this.draw = function(e) {
- this.obj.style.display = "";
- var px = (e.clientX - this.x)>0?this.x:e.clientX;
- var py = (e.clientY - this.y)>0?this.y:e.clientY;
- if(e.clientX==this.x) {
- this.obj.style.borderLeft = "0px";
- } else {
- this.obj.style.borderLeft = "1px solid #00f";
- }
- if(e.clientY==this.y) {
- this.obj.style.borderTop = "0px";
- } else {
- this.obj.style.borderTop = "1px solid #00f";
- }
- this.obj.style.left = px;
- this.obj.style.top = py;
- this.obj.style.width = Math.abs(e.clientX - this.x);
- this.obj.style.height = Math.abs(e.clientY - this.y);
- }
- this.clear = function() {
- $("layer").removeChild(this.obj);
- }
- this.initial();
- }
- function setup(e) {
- drag = true;
- a = new Class();
- ee = e?e:window.event;
- a.move(e.clientX, e.clientY);
- }
- function draw(e) {
- ee = e?e:window.event;
- if(drag) {
- a.draw(e);
- }
- }
- function clear() {
- drag = false;
- a.clear();
- }
- function $(id) {
- return document.getElementById(id);
- }
- $("layer").onmousedown = setup;
- $("layer").onmousemove = draw;
- $("layer").onmouseup = clear;
- </script>
- </body>
- </html>
- A javascript selector
- Turn a graph into a selector?
- selector
- selector
- @selector
- selector
- @selector
- Selector
- @selector
- @selector
- Selector
- selector
- @selector
- selector
- selector
- Selector
- @selector
- SELECTOR
- Code::Blocks 多线程程序的编译
- awk文本处理总结
- 软件开发--对未来的迷茫
- Hibernate Search, Lucene 与 JBoss Seam
- 数据链路
- A javascript selector
- 神七顺利回家
- PDF417lib Java
- 无论如何zoom,原点坐标不变
- 放假啦
- Hibernate 映射视图的联合主键
- RTP:实时应用程序传输协议(中文协议定义)
- 最新asp.net 发邮件
- 结构化异常处理和C++的异常处理区别