30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
// xWinClass, Copyright 2003-2005 Michael Foster (Cross-Browser.com)
|
|
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL
|
|
|
|
// xWinClass Object Prototype
|
|
|
|
function xWinClass(clsName, winName, w, h, x, y, loc, men, res, scr, sta, too)
|
|
{
|
|
var thisObj = this;
|
|
var e='',c=',',xf='left=',yf='top='; this.n = name;
|
|
if (document.layers) {xf='screenX='; yf='screenY=';}
|
|
this.f = (w?'width='+w+c:e)+(h?'height='+h+c:e)+(x>=0?xf+x+c:e)+
|
|
(y>=0?yf+y+c:e)+'location='+loc+',menubar='+men+',resizable='+res+
|
|
',scrollbars='+scr+',status='+sta+',toolbar='+too;
|
|
this.opened = function() {return this.w && !this.w.closed;};
|
|
this.close = function() {if(this.opened()) this.w.close();};
|
|
this.focus = function() {if(this.opened()) this.w.focus();};
|
|
this.load = function(sUrl) {
|
|
if (this.opened()) this.w.location.href = sUrl;
|
|
else this.w = window.open(sUrl,this.n,this.f);
|
|
this.focus();
|
|
return false;
|
|
};
|
|
// Closures
|
|
// this == <A> element reference, thisObj == xWinClass object reference
|
|
function onClick() {return thisObj.load(this.href);}
|
|
// '*' works with any element, not just A
|
|
xGetElementsByClassName(clsName, document, '*', bindOnClick);
|
|
function bindOnClick(e) {e.onclick = onClick;}
|
|
}
|