Entry
function with end statement document.src = url; I want to open url in pop when I call this function.
Oct 13th, 2003 02:20
Mister Sokrates, ajay desai, Mister Sokrates
Do yo want to use simple popup window?
And with multiple times?
That is ... if popup opens, the send target there?
Here is some code (clean it up for your own needs).
Not very clean code, but ... its written long time ago... :)
################
// set wX or hY 0 if you want that dimension maximized
// i.e <a href="javascript:PhotoGallery
('myDir','100percent.htm','0','0')">?</a>
function PhotoGallery(Directory,NameOfPicOrPage,wX,hY) {
var dir = Directory,
windowName = "PhotoGallery",
w = 0,
h = 0;
var OnceOpened = 0;
// If you know the size of pic and if in HTML there is some extra
// space, (lets say for comments), then this is the space comment is
using.
// addSome variables shoud be actually as "input" -> ( ...
wX,wY,addSomeW, ... )
addSomeW = 175,
addSomeH = 20,
popW = wX + addSomeW,
popH = hY + addSomeH,
scrllBar = "yes",
size = "small",
leftPos = 0,
topPos = 0;
// slash testing - add slash if not there
// remove slash if dir lenght is 1
and is slash
if ((dir.length >= 2) && (dir.substring(dir.length-
1,dir.length) != "/" )) { dir = dir + "/" }
if ((dir.length = 1) && (dir == "/")) { dir = "" }
// make an number popup window, which h & w divides with 2
// and remove "addSome" anomalia because it is
// used later for testing if pop == addSome
if ((popW % 2) != 0){ popW = popW + 1; addSomeW = addSomeW +
1; }
if ((popH % 2) != 0){ popH = popH + 1; addSomeH = addSomeH +
1; }
// which is better??
// w = screen.availWidth - 10;
// h = screen.availHeight - 30;
w = screen.Width - 10;
h = screen.Height - 60;
// if undef
// or if there is some anomalia (is it possible??)
// or if you need much smaller popups than window
// i.e if(screen.Width <= 640) { w = 450; }
// if(screen.Width <= 800) { w = 600; }
// if(screen.Width <= 1024) { w = Math.round(screen.Width *
0.9); }
// Cacscading or Non Cascading, by % ... Javascript is pure fun :=)
if ((w <= 0) || (screen.Width < 640)) { w = 450; }
if ((h <= 0) || (screen.Height < 450)) { h = 450; }
// if too damn big popup (may NOT be removed)
if ((popW > w) || ((addSomeW != 0)&&(popW == addSomeW)&&(w >
0)))
{ leftPos = "ziro"; popW = w; scrllBar = "yes"; size
= "big"; }
if ((popH > h) || ((addSomeH != 0)&&(popH == addSomeH)&&(h >
0)))
{ topPos = "ziro"; popH = h; scrllBar = "yes"; size
= "big"; }
// if it wasn't the too damn big popup
if (size == "small"){
scrllBar = "no";
popW = popW - 10;
popH = popH - 10;}
// some positioning for a) to damn big and undef popups b) normal popups
if (leftPos == "ziro"){ leftPos = 0 } else { leftPos = (w -
popW)/2 }
if (topPos == "ziro"){ topPos = 0 } else { topPos = (h -
popH)/2 }
if(OnceOpened != 0) {
if(window.pop.closed) {
pop = window.open(
dir + NameOfPicOrPage,
windowName,
"width=" + popW +
",height=" + popH +
",scrollbars=" + scrllBar +
",screenX=" + leftPos +
",screenY=" + topPos +
",left=" + leftPos +
",top=" + topPos +
",toolbar=no" +
",status=no" +
",resize=no" +
",menubars=no" +
",directories=no"
);
}
else { pop.location.href = NameOfPicOrPage }
}
else {
pop = window.open(
dir + NameOfPicOrPage,
windowName,
"width=" + popW +
",height=" + popH +
",scrollbars=" + scrllBar +
",screenX=" + leftPos +
",screenY=" + topPos +
",left=" + leftPos +
",top=" + topPos +
",toolbar=no" +
",status=no" +
",resize=no" +
",menubars=no" +
",directories=no"
);
OnceOpened = 1;
}
// If this script is used many times row then previous window must be
closed
// ie. <body onBlur="self.close"> ... Other wise it do not resize
window.
// Sux if previous window not closed :(
// pop.focus();
// (Notice (when 4rd generation browsers arrived): could use resizeing
and moving...)
}
// function reallyClosed() {
// if(OnceOpened != 0) {
// if(!window.pop.closed) {
// pop.opener='';
// pop.close();
// OnceOpened = 0;
// }
// }
// }