JAVASCRIPT Question

Discussion in 'Web Design & Coding' started by vern, Mar 8, 2003.

  1. vern

    vern Dominus Political User Folding Team

    Messages:
    1,571
    Location:
    Minnesota, USA
    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.
     
  2. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    you'd need something like this in the page that pops-up...
    <body topmargin="0" leftmargin="0">
     
  3. concrete

    concrete Guest

    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

    Add the scrollbars argument;

    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
     
  4. muzikool

    muzikool Act your wage. Political User

    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!
     
  5. vern

    vern Dominus Political User Folding Team

    Messages:
    1,571
    Location:
    Minnesota, USA
    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.

    I only had to add this to make the pop-up window resize correctly to the image.
    You call the script like so: