Struppi: _blank - Grösse definieren

Beitrag lesen

popup():
[code lang=javascript]
function popup(src,w,h,x,y) {
var options="", popupURL, popupName, popupWin;
if(typeof(x)=="number") options+=",left="+x;
if(typeof(y)=="number") options+=",top="+y;
if(typeof(w)=="number") options+=",width="+w;
if(typeof(h)=="number") options+=",height="+h;
lastParam=popup.arguments[popup.arguments.length-1];
if(typeof(lastParam)=="string") {
  options+=","+lastParam;
} else {
  if(typeof(lastParam)=="boolean" && lastParam) {
   options+=",menubar=no"
  } else if(typeof(lastParam)!="boolean" || (typeof(lastParam)!="boolean" && !lastParam)) {
   options+=",menubar=yes,toolbar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes";
  }
}

if(options) { options=options.substring(1); }

Dein options Handling finde ich ein bisschen verzwirbellt.
var options = new Array();

f(typeof(x)=="number") options[options.length] = "left=" + x;
if(typeof(y)=="number") options[options.length] = "top="+y;
if(typeof(w)=="number") options[options.length] = "width="+w;
if(typeof(h)=="number") options[options.length] = "height="+h;

... den Rest spare ich mal aus, da das mit dem lastParam irgendwie seltsam ist.

und dann:

window.open( ...., options.join(',') );

if(typeof(src)=="object") {
  popupURL=(src.href)?src.href:"about:blank";

about:blank führt dazu, dass du in Opera das Fenster nicht beschreiben kannst. Läßt du aber about:blank weg erzeugt der IE 3 einen Fehler, ich persönlich ignoriere lieber die Fehlermeldung im IE 3 als das ich Opera nutzer ausschliesse. Aber das ist Geschmacksache.

Struppi.