Results 1 to 5 of 5

Thread: Modify Script.

  1. #1
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Modify Script.

    Hi Everybody.

    I'm here for the 1st time and I have absolutly no clue about scripting.
    Once I managed to to add a script for a popup window to my site, but now I want this scrpt to be modified a little if possible.
    Here the page where this appears:
    http://www.tommys-service-enterprise...ang%20Paya.htm
    If you click the image in the middle of that page a window pops up, but now I want this popup window appear centered.
    Can this scropt be modified to do this?
    -----------------------------------------------------------------------
    </body>

    <HTML>
    <HEAD>
    <TITLE>Popup</TITLE>
    <script language='javascript'>
    var arrTemp=self.location.href.split("?");
    var picUrl = (arrTemp.length>0)?arrTemp[1]:"";
    var NS = (navigator.appName=="Netscape")?true:false;

    function FitPic() {
    iWidth = (NS)?window.innerWidth:document.body.clientWidth;
    iHeight = (NS)?window.innerHeight:document.body.clientHeight;
    iWidth = document.images[0].width - iWidth;
    iHeight = document.images[0].height - iHeight;
    window.resizeBy(iWidth, iHeight);
    self.focus();
    };
    </script>
    </HEAD>
    <BODY bgcolor="#000000" onload='FitPic();' topmargin="0"
    marginheight="0" leftmargin="0" marginwidth="0">
    <script language='javascript'>
    document.write( "<img src='" + picUrl + "' border=0>" );
    </script>
    </BODY>
    </HTML>
    -----------------------------------------------------------------------
    Please help me out here.
    Thanks in advance.
    Cheng

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Yes but, it is not a good idea. In fact, with certain security settings in some browsers, the script you have will not work even as it is. A better approach is to size and position the pop up before it opens, not after. This requires the script to be different and to be on the launching page, not on the launched page as you currently have it. Here is a good script generator you can use for that:

    Popup Window Generator
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Hi John.
    Thanks for your reply.
    I used the script generator and it worked so far, exept one thing.
    Please have a look at this example:
    http://www.mbs-paper.com/pop/popup.htm
    As you can see the popup is centerd, but the image inside the window does not fit exactly to the edges.
    If you could help me get rid of this I would be happy.
    Thanks again.
    Cheng

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Replace this:

    Code:
    win=window.open(mypage,myname,settings);}
    // -->
    with this (notice that the closing } has been moved):

    Code:
    win=window.open('',myname,settings);
    win.document.write('<body style="margin:0;padding:0;"><img src="'+mypage+'">');
    win.document.close();
    }
    // -->
    If you want the pop up to close when the user shifts focus away from it, use:

    Code:
    win=window.open('',myname,settings);
    win.document.write('<body style="margin:0;padding:0;" onblur="self.close()"><img src="'+mypage+'">');
    win.document.close();
    }
    // -->
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Hi John.
    You're the man!
    Nice job!
    It's working fine now.
    I fell like a scripting guru.
    You can have a look here:
    http://www.mbs-paper.com/pop/popup.htm
    There is one thing though.
    Would it be possible to get rid of the top frame in blue and the grey one down below, like they do in advertising popups?
    I know usualy they are using flash or swf files and no images to do this, but maybe it's possible with this here as well.
    If so, please give me hint on how to manage.
    Thanks again and as I said before.
    You're the man!
    So long.
    Cheng

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •