есть два класса - PopupWindow для вывода окошка в каком то месте страницы, все нормально работает, и InspectFormWindow который должен выводиться при наведении мышкой на форму и показывать данные о форме для всех ее элементов(имя элемента, тип элемента, значение), но этот класс не работает а ошибку найти не получается вот сам этот класс: | Код | function InspectFormWindow(title, x, y, form) { //формируем текст в виде таблицы var table = "<table>"; for(var i = 0; i < form.elements.length; i++) { table += "<tr><td>" + form.elements[i].name + "</td><td>" + form.elements[i].type + "</td><td>" + form.elements[i].value + "</td></tr>"; } table += "</table>"; PopupWindow.call(this, title, x, y, table); } extend(InspectFormWindow, PopupWindow);
function tableFromFormData(form) { var table = "<table>"; for(var i = 0; i < form.elements.length; i++) { table += "<tr><td>" + form.elements[i].name + "</td><td>" + form.elements[i].type + "</td><td>" + form.elements[i].value + "</td></tr>"; } table += "</table>"; return table; }
var iwnd = new InspectFormWindow();
|
у самой формы аттрибуты стоят такие: | Код | <form name="mainform" method="post" action="mailto:тут_был_емаил_для_примера" onsubmit="return check();" onMouseOver="iwnd.setText(tableFromFormData(this));" onMouseOut="iwnd.hide()"> </form>
|
вот на всякий случай еще полный текст классов: | Код | function addEvent(elem, type, handler) { if (elem.addEventListener) { elem.addEventListener(type, handler, false) } else { elem.attachEvent("on" + type, handler) } } //----------------------------------------------------------------------------------------------- function PopupWindow(title, x, y, text) { var top, left, header, content, self = this;
this.getTitle = function() {return header;} this.setTitle = function(newTitle) { self.title.innerHTML = newTitle; header = newTitle; }
this.getText = function() {return content;} this.setText = function(newContent) { self.text.innerHTML = newContent; content = newContent; }
this.getTop = function() {return top;} this.setTop = function(newY) { self.wnd.style.top = newY + "px"; top = newY; }
this.getLeft = function() {return left;} this.setLeft = function(newX) { self.wnd.style.left = newX + "px"; left = newX; }
this.wnd = document.createElement("div"); this.wnd.className = "wnd";
this.title = document.createElement("div"); this.title.className = "title";
this.close = document.createElement("div"); this.close.className = "close"; this.close.innerHTML = "X"; this.closeClick = function() { self.hide(); }
this.text = document.createElement("div"); this.text.className = "text";
this.wnd.appendChild(this.title); this.wnd.appendChild(this.text); this.wnd.appendChild(this.close);
this.startMove = 0; this.startMoveX = 0; this.startMoveY = 0;
this.mouseDown = function(event) { e = event || window.event; //var t = event.target || event.srcElement; if (!e.which && e.button) { if (e.button & 1) e.which = 1; else if (e.button & 4) e.which = 2; else if (e.button & 2) e.which = 3; } if (e.which == 1) { self.startMove = 1; if (e.pageX == null && e.clientX != null) { var html = document.documentElement; var body = document.body; e.pageX = e.clientX + (html && html.scrollLeft || body && body.scrollLeft) - html.clientLeft; e.pageY = e.clientY + (html && html.scrollTop || body && body.scrollTop) - html.clientTop; } self.startMoveX = e.pageX - self.getLeft(); self.startMoveY = e.pageY - self.getTop(); self.wnd.className = 'wnd moved'; } }
this.mouseUp = function(event) { e = event || window.event; //var t = event.target || event.srcElement; if (!e.which && e.button) { if (e.button & 1) e.which = 1; else if (e.button & 4) e.which = 2; else if (e.button & 2) e.which = 3; } if (e.which == 1) { self.startMove = 0; self.wnd.className = 'wnd'; } return false; }
this.mouseMove = function(event) { if (self.startMove) { e = event || window.event; if (e.pageX == null && e.clientX != null) { var html = document.documentElement; var body = document.body; e.pageX = e.clientX + (html && html.scrollLeft || body && body.scrollLeft) - html.clientLeft; e.pageY = e.clientY + (html && html.scrollTop || body && body.scrollTop) - html.clientTop; } self.setLeft(e.pageX - self.startMoveX); self.setTop (e.pageY - self.startMoveY); } return false; }
addEvent(this.title,'mousedown',this.mouseDown); addEvent(this.title,'mouseup', this.mouseUp); addEvent(this.title,'mousemove',this.mouseMove); addEvent(this.close,'click',this.closeClick);
this.setLeft(x); this.setTop(y); this.setTitle(title); this.setText(text); document.body.appendChild(this.wnd); } //----------------------------------------------------------------------------------------------- PopupWindow.prototype.moveTo = function(x,y) { this.setLeft(x); this.setTop(y); } //----------------------------------------------------------------------------------------------- PopupWindow.prototype.show = function() { this.wnd.style.visibility = "visible"; } //----------------------------------------------------------------------------------------------- PopupWindow.prototype.hide = function() { this.wnd.style.visibility = "hidden"; } //----------------------------------------------------------------------------------------------- function extend(Child, Parent) { var F = function() { }; F.prototype = Parent.prototype; Child.prototype = new F(); Child.prototype.constructor = Child; Child.superclass = Parent.prototype; } function PhotoViewWindow(title, x, y, url) { var imgHTML = '<p align=center><img src="' + url + '" alt="' + title + '" width=667 height=500 padding=0></p>'; PopupWindow.call(this, title, x, y, imgHTML); } //----------------------------------------------------------------------------------------------- extend(PhotoViewWindow, PopupWindow);
function InspectFormWindow(title, x, y, form) { //формируем текст в виде таблицы var table = "<table>"; for(var i = 0; i < form.elements.length; i++) { table += "<tr><td>" + form.elements[i].name + "</td><td>" + form.elements[i].type + "</td><td>" + form.elements[i].value + "</td></tr>"; } table += "</table>"; PopupWindow.call(this, title, x, y, table); } extend(InspectFormWindow, PopupWindow);
function tableFromFormData(form) { var table = "<table>"; for(var i = 0; i < form.elements.length; i++) { table += "<tr><td>" + form.elements[i].name + "</td><td>" + form.elements[i].type + "</td><td>" + form.elements[i].value + "</td></tr>"; } table += "</table>"; return table; }
var iwnd = new InspectFormWindow();
|
в чем ошибка? или можно как-нибудь лучше это реализовать? Это сообщение отредактировал(а) anatox91 - 26.10.2011, 16:09
--------------------
The code is the design © Sony VAIO VGN-FW480J 
|