Click to See Complete Forum and Search --> : window question...


ShrineDesigns
01-04-2003, 05:08 PM
is there a way to resize the window to the new width and height and Xpos and Ypos and reload it to show the new image ???

is there a shorter way to achieve this:

<script language="JavaScript" type="text/JavaScript">
<!--
function largeView(dir,img,W,H){
var base = "http://www.angelfire.com/";
var sbase = "/images/shirow/shirow"
var dirStr = new Array();
dirStr[1] = base + "gundam/tallgeese1" + sbase + img + ".jpg";
dirStr[2] = base + "anime4/shirow1" + sbase + img + ".jpg";
var imgStr = '\" width=\"' + W + '\" height=\"' + H + '\" border=\"0\">';
var sw = (screen.availWidth - W) / 2;
var sh = (screen.availHeight - H) / 2;
var x = Math.floor(sw);
var y = Math.floor(sh);
if (W >= screen.width && H >= screen.availHeight) {
winSet = "height=" + (screen.height - 57) + " width=" + (screen.width - 9) + " top=0 left=0 scrollbars=yes";
}
else if (W >= screen.width) {
winSet = "height=" + (H + 16) + " width=" + (screen.width - 9) + " top=" + y + " left=0 scrollbars=yes";
}
else if (H >= screen.height) {
winSet = "height=" + (screen.height - 57) + " width=" + (W + 16) + " top=0 left=" + x + " scrollbars=yes";
}
else if (W <= screen.width && H <= screen.availHeight) {
winSet = "height=" + H + " width=" + W + " top=" + y + " left=" + x;
}
if (dir == 1){
rtnStr = dirStr[1];
}
else if (dir == 2){
rtnStr = dirStr[2];
}
var str = window.open('#','largeView',winSet);
str.document.write('<html><head><title>ANIMESHRINE1134 IMAGE GALLERY<\/title><\/head><body style=\"margin:0px;\">');
str.document.write('<img src=\"' + rtnStr + imgStr);
str.document.write('<\/body><\/html>');
}
//-->
</script>

thanks

AdamBrill
01-04-2003, 10:44 PM
Since the original source opened it in a new window, try this. Put this function in the <head>:


function Open_window(img)
{
test=new Image;
test.src=img;
posx=Math.floor((screen.availWidth - test.width) / 2);
posy=Math.floor((screen.availHeight - test.height) / 2);
if(test.height<100) H=100;
if(test.width<100) W=100;
window.open(img,null,"height="+H+",width="+W+",top="+posy+",left="+posx+",status=no,titlebar=no,toolbar=no,menubar=no,location=no");
}


Then, call it like this:


<a href="javascript:Open_window('http://www.whatever.com/Image.gif')">Click Here!</a>
In the above line, javascript doesn't have a space.

Make sure you always put a direct link(http://www.whatever.com/image.gif not just image.gif), then is should work fine.

ShrineDesigns
01-04-2003, 11:23 PM
thanks dave and adam

my script uses the top and left for the window position;
but NN doesn't support those attributes and you need signed scripts to use the screenX and screenY; is there a way to work around this ???

AdamBrill
01-04-2003, 11:24 PM
Nope, I didn't know that. I was running it off of my computer so it didn't have much loading time. :) Thanks for pointing it out though, I'll fix it in a jiffy! Just out of curiosity, what would it return if the image was half loaded?

AdamBrill
01-04-2003, 11:30 PM
The update:


function Open_window(img,W,H)
{
posx=Math.floor((screen.availWidth - W) / 2);
posy=Math.floor((screen.availHeight - H) / 2);
if(H<100) H=100;
if(W<100) W=100;
window.open(img,null,"height="+H+",width="+W+",top="+posy+",left="+posx+",status=no,titlebar=no,toolbar=no,menubar=no,location=no");
}


That's the function, and call it like this:


<a href="javascript:Open_window('http://www.somedomain.com/image.gif',width,height)">Click Here!</a>

were width is the width of the image and height is the height of it.

And, about Netscape, what version are you using? I'm using version 7 and it works just fine. So, I'm not sure what to tell you...

ShrineDesigns
01-04-2003, 11:47 PM
i use NN 7 also; the smaller size image isn't really an issue; but for the large ones the window is placed where ever leave some of the window hidden behind the edges of the screen and i don't think NN 7 has adopted the top and left poitioning for a window

ShrineDesigns
01-05-2003, 05:20 PM
alright thank you adam and dave