Resize an existing popup window

N

Nigel Molesworth

I'm using a combination of various "googled" scripts to generate
borderless pop-ups when a thumbnail is clicked, see below. At present it
works OK, a new image takes the place of an old one, the pop up goes if
you close the parent etc.

My problem is that I would really like to resize an existing window if
one exists, rather than close and make a new one. See ******

I've tried .resizeTo() but it seems to come up with a tiny window.

Any thoughts?




var popwin='';

function viewPic(img)
{
picfile = new Image();
picfile.src =(img);
fileCheck(img);
}


function fileCheck(img)
{
if( (picfile.width!=0) && (picfile.height!=0) )
{
checkExisting(img);
}
else
{
funzione="fileCheck('"+img+"')";
intervallo=setTimeout(funzione,50);
}
}


function checkExisting(img)
{
if (popwin.location && !popwin.closed)
{
popwin.close();
makeWindow(img)
//popwin.location.href = img; need a tidy here, but it works ******
// popwin.focus();
}
else {makeWindow(img)}
}


function makeWindow(img)
{
ht = picfile.height;
wd = picfile.width;

var args= "height=" + ht + ",innerHeight=" + ht;
args += ",width=" + wd + ",innerWidth=" + wd;

popwin=window.open("","_blank",args)
popwin.document.open()
popwin.document.write('<html><head><title>'+img+'</title></head><body
bgcolor=white scroll=no topmargin=0 leftmargin=0 rightmargin=0
bottomargin=0 marginheight=0 marginwidth=0> <div style="position:
absolute; top:0px;left:0px"><a href="javascript:window.close()"> <img
src="'+img+'" width="'+wd+'" height="'+ht+'"
border="0"></a></div></body></html>')
popwin.document.close()
}


function tidy() {
if (popwin.location && !popwin.closed) {
popwin.close(); }
}

// Based on JavaScript provided by Peter Curtis at www.pcurtis.com &
// http://www.therotunda.net/code/autosized-popup-window.html -->
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top