Results 1 to 6 of 6

Thread: 2 Cmotion pop-up window questions

  1. #1
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 2 Cmotion pop-up window questions

    Script : Cmotion
    http://dynamicdrive.com/dynamicindex...iongallery.htm

    Hi,

    Cmotion is great but two small issues ..

    1. In IE6, the image in the pop-up window is offset by 10 pixels ie there is a 10px white band to the left and top of the image. Consequently, there is 10px missing from right and bottom of image. I have set the image dimension correctly. Works fine in Firefox.

    2. Is there anyway to make the pop-up window close when the user clicks back on the page, rather than spawning a new window each time they click a thumbnail (without closing the previous pop-up)?

    Thanks.

    Walt

  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

    Not exactly. Try replacing this:
    Code:
    function enlargeimage(path, optWidth, optHeight){ //function to enlarge image. Change as desired.
    var actualWidth=typeof optWidth!="undefined" ? optWidth : "600px" //set 600px to default width
    var actualHeight=typeof optHeight!="undefined" ? optHeight : "500px" //set 500px to  default height
    var winattributes="width="+actualWidth+",height="+actualHeight+",resizable=yes"
    window.open(path,"", winattributes)
    }
    with this:
    Code:
    var win = null;
    function enlargeimage(path, optWidth, optHeight){ //function to enlarge image. Change as desired.
    if(win&&!window.opera)
    win.close()
    var actualWidth=typeof optWidth!="undefined" ? optWidth : "600px" //set 600px to default width
    var actualHeight=typeof optHeight!="undefined" ? optHeight : "500px" //set 500px to  default height
    var winattributes="width="+actualWidth+",height="+actualHeight+",top=250,left=250,resizable"
    win = window.open('','', winattributes)
    win.document.write('<title>Close Window to Exit</title>');
    win.document.write('<body bgcolor="#dddddd"  text="#000000" style="margin:0;padding:0;overflow:hidden;">');
    win.document.write('<img width="'+(actualWidth)+'" height="'+(actualHeight)+'" galleryimg="no" src="'+path+'" />');
    win.document.close();
    win.focus();
    }
    It is now only good for images though. Before, a page could be popped up as well. Refinements are possible.
    - John
    ________________________

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

  3. #3
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Many thanks.

    This sorts out problem 1 and helps with 2

    I've no idea about js but I have a Dreamweaver extension which pops-up open a window (the exact size of any image) but also closes on click back on main page. Here's the head script. Maybe you can understand it and it may help with this query !

    ---
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function openPictureWindow_Fever(imageType,imageName,imageWidth,imageHeight,alt,posLeft,posTop) { // v4.01
    newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
    newWindow.document.open();
    newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">');
    if (imageType == "swf"){
    newWindow.document.write('<object classid=\"clsid27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
    newWindow.document.write('<param name=movie value=\"'+imageName+'\"><param name=quality value=high>');
    newWindow.document.write('<embed src=\"'+imageName+'\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
    newWindow.document.write('</embed></object>'); }else{
    newWindow.document.write('<img src=\"'+imageName+'\" width='+imageWidth+' height='+imageHeight+' alt=\"'+alt+'\">'); }
    newWindow.document.write('</body></html>');
    newWindow.document.close();
    newWindow.focus();
    }
    //-->
    </script>
    ----

    Note - grin icon is middle is "colon D" with no space.

    Walt.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Try <body onclick="win.close()"> for the close-on-click thing.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    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

    I had tried that Twey but, the window then closes as it opens (all onclick). I just had another idea though, make the new window itself close onblur(). That would make our enlargeimage function look like this:
    Code:
    function enlargeimage(path, optWidth, optHeight){ //function to enlarge image. Change as desired.
    var actualWidth=typeof optWidth!="undefined" ? optWidth : "600px" //set 600px to default width
    var actualHeight=typeof optHeight!="undefined" ? optHeight : "500px" //set 500px to  default height
    var winattributes="width="+actualWidth+",height="+actualHeight+",top=250,left=250,resizable"
    var win = window.open('','', winattributes)
    win.document.write('<title>Close Window to Exit</title>');
    win.document.write('<script>window.onblur=function(){self.close();}<'+'/'+'script>')
    win.document.write('<body bgcolor="#dddddd"  text="#000000" style="margin:0;padding:0;overflow:hidden;">');
    win.document.write('<img width="'+(actualWidth)+'" height="'+(actualHeight)+'" galleryimg="no" src="'+path+'" />');
    win.document.close();
    }
    We can also dispense with the line:
    Code:
    var win = null;
    - John
    ________________________

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

  6. #6
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Excellent. Perfect. Thanks!

    Walt.

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
  •