JAVASCRIPT Question

vern

Dominus
Political Access
Joined
2 Mar 2002
Messages
1,572
I have this code ... which when called pops up a bigger version of an image and resizes the a new window according to the size of the image.

------

<SCRIPT language="JavaScript">
<!-- Begin
function CaricaFoto(img){
foto1= new Image();
foto1.src=(img);
Controlla(img);
}
function Controlla(img){
if((foto1.width!=0)&&(foto1.height!=0)){
viewFoto(img);
}
else{
funzione="Controlla('"+img+"')";
intervallo=setTimeout(funzione,20);
}
}
function viewFoto(img){
largh=foto1.width;
altez=foto1.height;
stringa="width="+largh+",height="+altez;
finestra=window.open(img,"",stringa);
}
// End -->
//-->
</script>

-------

My problem is that the top and left edges of the window that pops up stilll has a bit of blank space. Anyone know how I could fix this? If anyone has code that does the exact same thing I'm trying to do, but better ... I'd appreciate it if you shared it with me.
 
you'd need something like this in the page that pops-up...
<body topmargin="0" leftmargin="0">
 
The reason is in the window.open method. As the window src is just an image, there is no html so margins dont come into it.

In your window.open argument

largh=foto1.width;
altez=foto1.height;
stringa="width="+largh+",height="+altez;
finestra=window.open(img,"",stringa);

Add the scrollbars argument;

largh=foto1.width;
altez=foto1.height;
stringa="width="+largh+",height="+altez + ",scrollbars=no";
finestra=window.open(img,"",stringa);

Even though the window doesnt display scrollbars, IE tends to leave the area free "in case" you need scrollbars. If you implicitly tell it not to, it wont
 
I have a question regarding this exact issue. I'm using DreamWeaver creating some webpages with just HTML. I don't know JavaScript, but I would like the pic links to pop up in a new window sized to the image. Right now I've just got the image opening up in a normal browser window. Can someone walk me through how to do this, or point me to a good guide? Thanks!
 
I got this fixed. If you haven't found an alternative to your problem ... here is the code... you only need to add this to <head> of your page.

<SCRIPT language="JavaScript">
function CaricaFoto(img){
foto1= new Image();
foto1.src=(img);
Controlla(img);
}
function Controlla(img){
if((foto1.width!=0)&&(foto1.height!=0)){
viewFoto(img);
}
else{
funzione="Controlla('"+img+"')";
intervallo=setTimeout(funzione,20);
}
}
function viewFoto(img){
largh=foto1.width;
altez=foto1.height;
stringa="width="+(largh)+",height="+(altez);
finestra=window.open(img,"",stringa);
var s = finestra.document.body.style;
s.margin = '0'; s.padding = '0';
}
</script>

I only had to add this to make the pop-up window resize correctly to the image.
var s = finestra.document.body.style;
s.margin = '0'; s.padding = '0';

You call the script like so:

<a href="javascript:CaricaFoto('images/pic00.JPG')">



Originally posted by muzikool
I have a question regarding this exact issue. I'm using DreamWeaver creating some webpages with just HTML. I don't know JavaScript, but I would like the pic links to pop up in a new window sized to the image. Right now I've just got the image opening up in a normal browser window. Can someone walk me through how to do this, or point me to a good guide? Thanks!
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back