In a comment on a previous post I wrote about Enhancing CFWindow with JavaScript, Ebenezer asked the question:

"CFwindows is quite nice, but i need it to behave in a particular way. I want to remove the frame and the (x) close button. I want to use cfwindow to just "display the bigger size of an image on mouseover and close on mouse out. Anyone with an idea."

Below is an example of how to remove the toolbar and borders from the cfwindow and display the large image when you rollover the thumbnail.

Click here to see it in action.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>
<head>
   <title>CFWindow as Image onMouseOver Enlarger/Pop Up</title>
   <script language="JavaScript">
      //The init function removes the toolbox and makes sure the title is empty       
      init = function(){
         myWindow = ColdFusion.Window.getWindowObject('ImageWindow');
         myWindow.toolbox.remove();
         myWindow.header.remove();
         myWindow.setTitle('');
      }
      
      //the showImage function updates the body of the cfwindow with an img tag       //and resizes the cfwindow to fit the image       
      showImage = function(imgPath,width,height){
         myWindow = ColdFusion.Window.getWindowObject('ImageWindow');
   myWindow.body.update("<img src='" + imgPath + "' alt='' border='0'>");
   myWindow.setContentSize(width, height);
         ColdFusion.Window.show('ImageWindow');
      }
      
      //the hideImage is called by the onmouseout event       
      hideImage = function(){
         ColdFusion.Window.hide('ImageWindow');
      }
   </script>
   <!--- Override Styles to remove border from cfwindow --->
   <style>
   .x-dlg div.x-resizable-handle-north {
      background-image:none;
      border:0px none;
      }
   .x-dlg div.x-resizable-handle-south {
      background-image:none;
      border:0px none;
      height:0px;
      }
   .x-dlg div.x-resizable-handle-east {
      background-image:none;
      width:0px;
      border:0px none;
      margin-right:0pt;
      }
   .x-dlg div.x-resizable-handle-west {
      background-image:none;
      border:0px none;
      width:0px;
      }
   .x-dlg div.x-resizable-handle-northeast, .ytheme-gray .x-dlg div.x-resizable-handle-northeast {
      background-image:none;
      border:0px none;
      height:0px;
      width:0px;
      }
   .x-dlg div.x-resizable-handle-northwest, .ytheme-gray .x-dlg div.x-resizable-handle-northwest {
      background-image:none;
      border:0px none;
      height:0px;
      width:0px;
      }
   .x-dlg div.x-resizable-handle-southeast {ext-all.css (line 2247)
      background-image:none;
      border:0px none;
      height:0px;
      width:0px;
      }
   .x-dlg div.x-resizable-handle-southwest {ext-all.css (line 2255)
      background-image:none;
      border:0px none;
      height:0px;
      width:0px;
      margin-bottom:0px;
      margin-left:0px;
      }
   .x-dlg .x-dlg-dlg-body {
      border-color:none;
      border-style:none;
      border-width:0px 0px 0px;
      }
   </style>
</head>
<body>
<div align="center">
<img src="/Images/ScottGravator.jpg" alt="" border="0" onmouseover="showImage('/images/scottbennett.jpg',238,318);" onmouseout="hideImage();"><br>
(Mouseover to enlarge)
</div>
<!--- set up the image window. --->
<cfwindow
name="ImageWindow"
closable="true"
draggable="true"
height="300"
initShow="false"
minHeight="100"
minWidth="200"
modal="false"
refreshOnShow = "false"
resizable="true"
title=""
width="200">

</cfwindow>
<!--- call the init function when the cf ajax stuff is done loading --->
<cfset ajaxonload("init")>
</body>
</html>

And I also did pretty much the same thing here, but on this on you have to click the thumbnail to open the cfwindow, then click the large image to close the cfwindow. Click here to try it.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>
<head>
   <title>CFWindow as Image onClick Enlarger/Pop Up</title>
   <script language="JavaScript">
      //The init function removes the toolbox and makes sure the title is empty       
      init = function(){
         myWindow = ColdFusion.Window.getWindowObject('ImageWindow');
         myWindow.toolbox.remove();
         myWindow.header.remove();
         
         myWindow.setTitle('');
      }
      
      //the showImage function updates the body of the cfwindow with an img tag       //and resizes the cfwindow to fit the image       
      showImage = function(imgPath,width,height){
         myWindow = ColdFusion.Window.getWindowObject('ImageWindow');
   myWindow.body.update("<img src='" + imgPath + "' alt='' border='0' onclick='hideImage();'>");
   myWindow.setContentSize(width, height);
         ColdFusion.Window.show('ImageWindow');
      }
      
      //the hideImage is called by the onclick event in the img tag that       //is generated by the showImage function and just hides the cfwindow       
      hideImage = function(){
         ColdFusion.Window.hide('ImageWindow');
      }
   </script>
   <!--- Override Styles to remove border from cfwindow --->
   <style>
   .x-dlg div.x-resizable-handle-north {
      background-image:none;
      border:0px none;
      }
   .x-dlg div.x-resizable-handle-south {
      background-image:none;
      border:0px none;
      height:0px;
      }
   .x-dlg div.x-resizable-handle-east {
      background-image:none;
      width:0px;
      border:0px none;
      margin-right:0pt;
      }
   .x-dlg div.x-resizable-handle-west {
      background-image:none;
      border:0px none;
      width:0px;
      }
   .x-dlg div.x-resizable-handle-northeast, .ytheme-gray .x-dlg div.x-resizable-handle-northeast {
      background-image:none;
      border:0px none;
      height:0px;
      width:0px;
      }
   .x-dlg div.x-resizable-handle-northwest, .ytheme-gray .x-dlg div.x-resizable-handle-northwest {
      background-image:none;
      border:0px none;
      height:0px;
      width:0px;
      }
   .x-dlg div.x-resizable-handle-southeast {ext-all.css (line 2247)
      background-image:none;
      border:0px none;
      height:0px;
      width:0px;
      }
   .x-dlg div.x-resizable-handle-southwest {ext-all.css (line 2255)
      background-image:none;
      border:0px none;
      height:0px;
      width:0px;
      margin-bottom:0px;
      margin-left:0px;
      }
   .x-dlg .x-dlg-dlg-body {
      border-color:none;
      border-style:none;
      border-width:0px 0px 0px;
      }
   </style>
</head>
<body>

<div align="center">
<img src="/Images/ScottGravator.jpg" alt="" border="0" onclick="showImage('/images/scottbennett.jpg',238,318);"><br>
(click to enlarge)
</div>
<!--- set up the image window. --->
<cfwindow
name="ImageWindow"
closable="true"
draggable="true"
height="300"
initShow="false"
minHeight="100"
minWidth="200"
modal="false"
refreshOnShow = "false"
resizable="true"
title=""
width="200">

</cfwindow>
<!--- call the init function when the cf ajax stuff is done loading --->
<cfset ajaxonload("init")>
</body>
</html>

Related Blog Entries

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Anjorin Ebenezer's Gravatar Thanks... U're the best!
# Posted By Anjorin Ebenezer | 5/30/08 7:57 PM
James Moberg's Gravatar For these types of user interaction, I use and recommend "HighSlide JS". It's not specific to any version of ColdFusion and is highly customizable to use flash/sifr, iframe, hidden div, ajax and simple image links. Check it out:
http://vikjavev.no/highslide/
# Posted By James Moberg | 5/31/08 4:26 PM
Anjorin Ebenezer's Gravatar I checkd the site, its really nice... very impressive.. cant wait to try it out.

Thanks and to all you IT disciples, thanks for spreading the gospel.

Its more fun wen we share.

Cheers
# Posted By Anjorin Ebenezer | 5/31/08 10:33 PM
Scott Bennett's Gravatar @James,
I have used highslide on a few sites as well, and it is definitely a better way to go. I was actually going to mention that in this article, but forgot, so thanks for bringing it up.
# Posted By Scott Bennett | 5/31/08 11:27 PM
munna's Gravatar all i can say awesome stuff....
# Posted By munna | 9/13/08 6:14 PM
Mark Llewellyn's Gravatar Scott,

This works perfectly in FF3, but gives me an "exception thrown but not caught" error in IE [7] (debugger says in cfajax.js). At this point I am only interested in removing the title bar and borders, but using textual html content.

Any ideas? Also, I went to the Ext site to browse the docs but didn't find the reference for the remove method you call on the toolbox and header.

Thanks,
Mark
# Posted By Mark Llewellyn | 1/6/09 2:09 PM
Scott Bennett's Gravatar Mark,

I just tested it in IE 7 and it is working for me, so I'm not sure why it generated that error for you.

You can use textual html content the exact same way I used the html img tag. Just replace img tag in the line:

myWindow.body.update("<img src='" + imgPath + "' alt='' border='0' onclick='hideImage();'>");

with whatever html you want (you may need to use jsstringformat() to make the html javascript friendly)


Pretty much everything in ext extends the ext.element class which has a remove method.

http://extjs.com/deploy/ext/docs/output/Ext.Elemen...

If you are ever working with ext objects, you will want to be familiar with all the methods in the Ext.Element class.
# Posted By Scott Bennett | 1/6/09 3:28 PM
Mark Llewellyn's Gravatar Scott,

I'm embarassed to say that the code I copy-pasted to a test page here was not complete - a fresh copy of both your code samples work fine in IE7 <red-faced> There is something wrong in my main page with cfajax.js not finding my window id (name) and that is the root of where I have to look.

Thanks for the clarification on the ext.element class, I'm still getting my head wrapped around OO stuff!

Mark
# Posted By Mark Llewellyn | 1/6/09 3:38 PM
Scott Bennett's Gravatar Mark,

Make sure you are using firebug, it is a must have when dealing with javascript.

http://www.coldfusionguy.com/ColdFusion/blog/index...
# Posted By Scott Bennett | 1/6/09 3:42 PM
Mark Llewellyn's Gravatar I use Firebug in FF; but the error is only occurring when run in IE (and I really despise the way Script Editor works-- especially when compared to firebug).

Since all the other cfwindows defined on the page are not having a problem being displayed, I have to find out what sets this one apart. One thing is that the display call is being called within the function called by body onload, so perhaps something to do with late binding??
# Posted By Mark Llewellyn | 1/6/09 4:17 PM
Mark Llewellyn's Gravatar Figured it out. I was trying to define the cfwindow at bottom of body and do a getWindowObject on that during page load... it didn't like it in IE. I switched to just creating the window in JS, then setting the various attributes and showing it when done. I do a try-catch block to attempt showing the window, the catch block takes care of the create and modify section. Probably not good code practice, but it works well! <dang rookies... sheesh>

Thanks for your help Scott!
# Posted By Mark Llewellyn | 1/6/09 6:21 PM
sagar's Gravatar I am trying to use the function setContentSize but seems not working and always throws me an error on error console. Is it the right function?
# Posted By sagar | 2/12/10 4:22 PM
Sanchez's Gravatar this doesn't seem to work with cf9 is there an update?
# Posted By Sanchez | 7/5/12 12:56 PM
https://www.bababorses.de/Louis-Vuitton-Damier-Ebene-Canvas-Clapton-PM-Bag-N44243-Magnolia-2361-it.html https://www.bababorses.de/Louis-Vuitton-LV-Trainer-Men-s-Sneakers-Top-Quality-15-5322-it.html https://www.bababorses.de/Celine-Small-Cabas-Bag-In-Black-Leather-it-2087 https://www.bababorses.de/Louis-Vuitton-Heel-10cm-Call-Back-Sandals-Nude-6162-it.html https://www.bababorses.de/LOUIS-VUITTON-BREA-MM-Monogram-Vernis-Leather-In-Magenta-4069-it.html https://www.bababorses.de/Louis-Vuitton-Ring-09-557-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-LV-Square-Espadrilles-Slipper-Sandals-Brown-6371-it.html https://www.bababorses.de/Prada-Golden-Saffiano-Calfskin-Leather-Top-Handle-Bag-it-2956 https://www.bababorses.de/Dior-Diorissimo-Small-Bag-Black-Nappa-Leather-Silvery-Hardware-8001-it-22 https://www.bababorses.de/Louis-Vuitton-Idylle-Blossom-Charms-Necklace-Q94360-406-it.html https://www.bababorses.de/Louis-Vuitton-Color-Blossom-BB-Star-Pendant-Necklace-Red-Gold-309-it.html https://www.bababorses.de/Bvlgari-Serpenti-Original-Leather-Framed-Pochette-Sky-Blue-82121-it-1938 https://www.bababorses.de/Louis-Vuitton-Horizon-55-Trolley-Travel-Luggage-Bag-Taiga-Leather-M30331-Red-6892-it.html https://www.bababorses.de/Fendi-By-The-Way-Small-Croc-Satchel-White-it-2731 https://www.bababorses.de/Louis-Vuitton-Monogram-Canvas-and-PVC-Nano-Bag-M61114-3176-it.html https://www.bababorses.de/Louis-Vuitton-Sarah-Multicartes-Wallet-M61273-Hot-Pink-7624-it.html https://www.bababorses.de/louis-vuitton-speedy-30--Damier-Azur-Canvas-n44367-2300-it.html https://www.bababorses.de/Hermes-Birkin-35cm-cattle-skin-vein-Handbags-blue-golden-it-907 https://www.bababorses.de/Saint-Laurent-Baby-Sac-De-Jour-Bag-In-Rose-Grained-Leather-it-3322 https://www.bababorses.de/Louis-Vuitton-Twist-MM-M53531-M53532-2775-it.html https://www.bababorses.de/Louis-Vuitton-Sunglasses-133-978-it.html https://www.bababorses.de/Louis-Vuitton-Neverfull-MM-M54185-Black-2705-it.html https://www.bababorses.de/Prada-Saffiano-East-West-Medium-Tote-Bag-Nero-it-3042 https://www.bababorses.de/Louis-Vuitton-Compact-Wallet-in-Monogram-Canvas-M63041-7399-it.html https://www.bababorses.de/Prada-Mens-Leather-Pouch-3312-Black-it-3099 https://www.bababorses.de/Louis-Vuitton-Women-s-Escale-Lock-It-Flat-Mule-1A7TOX-Pink-5965-it.html https://www.bababorses.de/Fendi-Baguette-Micro-Monster-Bag-Purple-Multi-it-533 https://www.bababorses.de/Louis-Vuitton-LV-Angel-Stud-Earrings-M64293-435-it.html https://www.bababorses.de/Louis-Vuitton-Damier-Ebene-Canvas-Zippy-Wallet-Evasion-M61360-7219-it.html https://www.bababorses.de/LOUIS-VUITTON-CATOGRAM-SQUARE-SCARF-MP2266-4818-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Empreinte-Triangle-Shaped-Messenger-Bag-M54330-Black-3865-it.html https://www.bababorses.de/Balenciaga-Velo-Anthracite-store-it-1723 https://www.bababorses.de/Chloe-Marcie-Medium-Satchel-Bag-Cobalt-it-2283 https://www.bababorses.de/louis-vuitton-epi-leather-Soufflot-BB-bag-m55613-black-2580-it.html https://www.bababorses.de/Louis-Vuitton-Dauphine-MM-M55735-4512-it.html https://www.bababorses.de/Louis-Vuitton-Crafty-NeoNoe-MM-bag-black-M45497-2980-it.html https://www.bababorses.de/Louis-Vuitton-Men-Box-Bag-Shoulder-Body-Bag-M44157-Brown-3136-it.html https://www.bababorses.de/Prada-Saffiano-Double-Zip-Executive-Tote-Bag-Gray-it-3025 https://www.bababorses.de/Louis-Vuitton-Epi-Leather-NeoNoe-BB-Bucket-Bag-M53610-Indigo-2564-it.html https://www.bababorses.de/Saint-Laurent-Small-Monogram-Tassel-Satchel-In-Red-Crocodile-Leather-it-3158 https://www.bababorses.de/Louis-Vuitton-Iphone-Case-LV18-59-it.html https://www.bababorses.de/LOUIS-VUITTON--CLASSIC-MINI-PACKBACK-2872-it.html https://www.bababorses.de/Balenciaga-Velo-Anthracite-store-it-1723 https://www.bababorses.de/Louis-Vuitton-Monogram-Ebene-Canvas-Pegase-Legere-53-Business-Rolling-Luggage-6950-it.html https://www.bababorses.de/Louis-Vuitton-Crocodilien-Brillant-Capucines-Mini-Bag-N93429-Black-2231-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Hoodie-Jacket-Black-1526-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Coated-Canvas-Popincourt-PM-M43462--Raisin-3345-it.html https://www.bababorses.de/Louis-Vuitton-Lockme-Cabas-Tote-M55028-Black-4530-it.html https://www.bababorses.de/Givenchy-Antigona-Small-Leather-Satchel-Bag-Black-it-2432 https://www.bababorses.de/Louis-Vuitton-Monogram-Canvas-Small-Malle-Chain-Bag-3294-it.html https://www.bababorses.de/Louis-Vuitton-Epi-Leather-Zippy-Wallet-M62304-Red-7304-it.html https://www.bababorses.de/Louis-Vuitton-Iphone-Case-LV113-38-it.html https://www.bababorses.de/Louis-Vuitton-Heel-10.5cm-Eyeline-Pumps-Python-Pattern-Suede-Black-5999-it.html https://www.bababorses.de/LOUIS-VUITTON-PEGASE-LEGERE-REGATTA-N41620-MONOGRAM-CANVAS-6974-it.html https://www.bababorses.de/Louis-Vuitton-Kimono-Wallet-M56175-Pink-7437-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Tapestry-Denim-Bidart-Espadrilles-Blue-5726-it.html https://www.bababorses.de/Louis-Vuitton-Women-s-Escale-Shirtdress-Blue-1709-it.html https://www.bababorses.de/Louis-Vuitton-Montaigne-MM-M41048-Black-4597-it.html https://www.bababorses.de/Louis-Vuitton-Heel-10cm-Crystals-Call-Back-Sandals-Suede-Red-6160-it.html https://www.bababorses.de/Hermes-Bolide-31cm-Togo-Leather-Green-Bag-it-1070 https://www.bababorses.de/Replica-Hermes-Wallet-H001-Wallet-Cow-Leather-Green-it-1558 https://www.bababorses.de/Celine-Medium-Luggage-Tote-Black-Brown-White-Bag-it-2168 https://www.bababorses.de/Louis-Vuitton-Pochette-Voyage-MM-Bag-Damier-Graphite-Canvas-Pixel-N60176-Green-7278-it.html https://www.bababorses.de/Fendi-Black-Snake-Veins-Leather-With-Beige-Ferrari-Leather-Top-handle-Bag-it-469 https://www.bababorses.de/Louis-Vuitton-All-over-Monogram-Sleeveless-Belted-Dress-Navy-1375-it.html https://www.bababorses.de/Louis-Vuitton-Ring-02-560-it.html https://www.bababorses.de/Louis-Vuitton-Iphone-Case-LV32-76-it.html https://www.bababorses.de/Louis-Vuitton-Dauphine-MM-M55071-Blue-4511-it.html https://www.bababorses.de/Louis-Vuitton-Supreme-Iphone-Case-White-Red-212-it.html https://www.bababorses.de/Louis-Vuitton-Epi-Smooth-Leather-Twist-Shoulder-Bag-MM-Pink-Black-2639-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Empreinte-Leather-Cosmetic-Pouch-Bag-M80502-Bouton-de-Rose-Pink-By-The-Pool-Capsule-Collection-4296-it.html https://www.bababorses.de/Louis-Vuitton-Bracelet-21-271-it.html https://www.bababorses.de/Louis-Vuitton-Heel-9.5-cm-Star-Trail-Ankle-Boots-Black-5511-it.html https://www.bababorses.de/Louis-Vuitton-Geronimos-Belt-Bag-M43502-Black-Epi-Leather-2646-it.html https://www.bababorses.de/Louis-Vuitton-Damier-Ebene-Canvas-Vavin-Chain-Wallet-N60222-Bordeaux-Red-7221-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Empreinte-Leather-Zippy-Coin-Purse-M80408-Cream-Saffron-By-The-Pool-Capsule-Collection-7741-it.html https://www.bababorses.de/Louis-Vuitton-Vintage-Monogram-Vernis-Bleecker-Box-Top-Handle-Bag-Burgundy-4172-it.html https://www.bababorses.de/Prada-Saffiano-Mini-Galleria-Crossbody-Bag-Beige-it-2708 https://www.bababorses.de/Louis-Vuitton-Sunglasses-39-1042-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Canvas-Leopard-Print-Onthego-Tote-Bag-M44674-Black-White-3232-it.html https://www.bababorses.de/Louis-Vuitton-Epi-Leather-Twist-PM-Bag-with-Crystal-embellished-Chain-M55412-White-2630-it.html https://www.bababorses.de/Fendi-Chameleon-Red-Cross-Veins-Leather-Tote-Bag-it-488 https://www.bababorses.de/Louis-Vuitton-Monogram-Canvas-Onthego-Tote-Bag-M44571-Kaki-3270-it.html https://www.bababorses.de/Fendi-Earth-Yellow-Leather-with-Multicolor-Striped-Fabric-Shopping-Handbag-it-771 https://www.bababorses.de/Louis-Vuitton-Croco-Pattern-Petite-Boite-Chapeau-Bag-Black-4090-it.html https://www.bababorses.de/Prada-Saffiano-Small-Double-Handle-Tote-Bag-Light-Gray-Pomice-it-2849 https://www.bababorses.de/Louis-Vuitton-Lvxlol-Speedy-BB-M45202-Golden-3125-it.html https://www.bababorses.de/Louis-Vuitton-Gloria-Flat-Open-Back-Loafers-Monogram-Canvas-5798-it.html https://www.bababorses.de/LOUIS-VUITTON-BREA-PM-Monogram-Vernis-leather-IN-MORDORE-4074-it.html https://www.bababorses.de/Replica-Hermes-Steve-H2810-Ladies-Shoulder-Bag-Cow-Leather-it-1428 https://www.bababorses.de/Louis-Vuitton-Noe-bag-M42226-Brown-3496-it.html https://www.bababorses.de/Louis-Vuitton-Damier-Azur-Canvas-I-2260-it.html https://www.bababorses.de/Christian-Dior-Multicolor-PeachYellow-Zipper-Wallet-118-it-223 https://www.bababorses.de/Fendi-By-the-Way-Small-Tricolor-Satchel-Bag-it-2916 https://www.bababorses.de/Prada-Medium-Vitello-Diano-Open-Tote-Bag-Pomice-it-2728 https://www.bababorses.de/Luxury-Hermes-Wallet-H001-Unisex-Wallet-it-1598 https://www.bababorses.de/Louis-Vuitton-Iphone-Case-LV42-104-it.html https://www.bababorses.de/Prada-Saffiano-Small-Gardeners-Tote-Bag-Blue-it-2803 https://www.bababorses.de/Louis-Vuitton-Sac-Tricot-Bag-Epi-Leather-Red-M52805-2736-it.html https://www.bababorses.de/Louis-Vuitton-Crazy-in-Lock-Strass-Bracelet-Silver-316-it.html