/    Sign up×
Community /Pin to ProfileBookmark

Auto resizing popup for IE and FF

I used the search and saw that this topic came up a couple times, but those threads couldn’t help me.

I need a auto resizing window for my image gallery.

I’ve tried this:

<script language=”javascript” type=”text/javascript”>
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName==”Netscape”)?1:0;
var isIE=(navigator.appName.indexOf(“Microsoft”)!=-1)?1:0;}
var optNN=’scrollbars=no’;
var optIE=’scrollbars=no’;
function popPic(imageURL,imageTitle){
if (isNN){imgWin=window.open(‘about:blank’,”,optNN);}
if (isIE){imgWin=window.open(‘about:blank’,”,optIE);}
with (imgWin.document){
writeln(‘<html><head><title>Loading…</title><style>body{margin:0px;}</style><meta http-equiv=”imagetoolbar” content=”no”>’);writeln(‘<sc’+’ript>’);
writeln(‘var isNN,isIE;’);writeln(‘if (parseInt(navigator.appVersion.charAt(0))>=4){‘);
writeln(‘isNN=(navigator.appName==”Netscape”)?1:0;’);writeln(‘isIE=(navigator.appName.indexOf(“Microsoft”)!=-1)?1:0;}’);
writeln(‘function reSizeToImage(){‘);writeln(‘if (isIE){‘);writeln(‘window.resizeTo(100,100);’);
writeln(‘width=122-(document.body.clientWidth-document.images[0].width);’);
writeln(‘height=100-(document.body.clientHeight-document.images[0].height);’);
writeln(‘window.resizeTo(width,height);}’);writeln(‘if (isNN){‘);
writeln(‘window.innerWidth=document.images[“up”].width;’);writeln(‘window.innerHeight=document.images[“up”].height;}}’);
writeln(‘function doTitle(){document.title=”‘+imageTitle+'”;}’);writeln(‘</sc’+’ript>’);
writeln(‘</head><body bgcolor=”000000″ scroll=”no” onload=”reSizeToImage();doTitle();self.focus()” onClick=”self.close()”>’);
writeln(‘<img alt=”Klicke um Fenster zu schliessen” name=”up” src=’+imageURL+’ style=”display:block”></body></html>’);
close();
}}
</script>

and it works fine in IE, but doesn’t work in FF. When I first tried it in FF, it worked, then I clicked my thumbnail again, and the popup cut a bit off at the side. I clicked again, it cut off more. Now when I click on it, it just shows a small portion of the window.

I also tried this:

[url]http://gil.davis.home.att.net/openit_example.htm[/url]

Also works in IE, but doesn’t work in FF – it keeps showing the ‘Loading’ text. I’ve tried it lots of times, and twice it showed up fine, but the rest of the time I just get ‘Loading’. The image on the example page also works in FF.

I did everything exactly like it’s in the examples, so why isn’t it working? Does anyone know a script for this that will work in IE and FF?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@ScrabbleJan 08.2007 — I don't use FF -- I use Avant browser. This is a script I added that works in it. You can try it in FF.......


function no_error(){

return true;

}

onerror=no_error;

function resizeimages() {

var AllImages = document.images;

numsized = 0;

if (AllImages != null)

{

for (i=0; i < AllImages.length; i++)

{

top.status="Checking image "+(i+1)+" of "+AllImages.length;

if (AllImages[i].width > document.body.clientWidth || AllImages[i].height > document.body.clientHeight){

numsized++;

height0=AllImages[i].height;

width0=AllImages[i].width;

verti = AllImages[i].height/document.body.clientHeight;

hori = AllImages[i].width/document.body.clientWidth;

if (verti > hori) {

AllImages[i].height = document.body.clientHeight-20;

AllImages[i].width = AllImages[i].height/height0*width0-20;

}

else {

AllImages[i].width = document.body.clientWidth-20;

AllImages[i].height = AllImages[i].width/width0
*
height0-20;

}

}

}

top.status="Resized "+numsized+" images of "+AllImages.length;

setTimeout("top.status='';",6000);

}

}



resizeimages();
Copy linkTweet thisAlerts:
@lynn168authorJan 08.2007 — Thanks for your reply.

Today the second script miraculously started working even though I didn't change a thing. :rolleyes:
×

Success!

Help @lynn168 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...