HTML
  Home arrow HTML arrow Page 3 - Maximizing and Restoring HTML Images: Laye...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

Maximizing and Restoring HTML Images: Layer Method
By: Chrysanthus Forcha
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2008-11-04

    Table of Contents:
  • Maximizing and Restoring HTML Images: Layer Method
  • The Method
  • Operation
  • Other Image Types

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Maximizing and Restoring HTML Images: Layer Method - Operation


    (Page 3 of 4 )

    The title attribute of an HTML element is used to produce a tool tip when the mouse pointer is over the element. Our image is given a title attribute, which says, “Click to maximize.” When the image is clicked it is maximized; the tool tip is changed to “Click to Restore.” When you click the maximized image, it is restored; the too tip says “Click to maximize” again.

    Unfortunately the tool tip may not show long enough for the user’s satisfaction. So to make sure that the user knows that he can click the image to maximize, on the web page, I have written just below the image, “Quality Watch (Click to maximize).”

    Accomplishing it with JavaScript and CSS

    I will give you the code before I explain how it works. There is one associated image file with the code. After going through this article, you can try the code.


    <html>


    <head>


    <style type="text/css">

    body {z-index:0}

    img.watch {width:187px; height:224px}

    </style>


    <script type="text/javascript">


    var maximized = false;


    //function to maximize the image.

    function maximizeFn()

    {

    document.getElementById("w1").style.position="absolute";

    document.getElementById("w1").style.zIndex="2";

    document.getElementById("w1").style.width="374";

    document.getElementById("w1").style.height="448";

    document.getElementById("w1").style.title="Click to Restore";

    maximized = true;

    }

     

    //function to restore the image.

    function restoreFn()

    {

    document.getElementById("w1").style.position="relative";

    document.getElementById("w1").style.zIndex="1";

    document.getElementById("w1").style.width="187";

    document.getElementById("w1").style.height="224";

    document.getElementById("w1").style.title="Click to Maximize";

    maximized = false;

    }

     

    //function to call either the maximizeFn() or restoreFn()

    function maxRest()

    {

    if (maximized == true)

    restoreFn();

    else

    maximizeFn();

    }


    </script>


    </head>


    <body>


    <table cellpadding="0" cellspacing="0">

    <tbody>

    <tr>

    <td colspan="2" align="center">

    <h1>Maximizing and Restoring HTML Image - Layer Method</h1>

    </td>

    </tr>

    <tr>

    <td width="100">&nbsp;

    </td>

    <td width="187" height="224" valign="top">

    <img id="w1" src="watch.jpg" class="watch" onclick="maxRest()" title="Click to Maximize" />

    </td>

    </tr>

    <tr>

    <td>&nbsp;

    </td>

    <td><b>Quality Watch</b> (click to maximize)

    </td>

    </tr>

    </tbody>

    </table>


    </body>


    </html>


    Explanation of code

    An HTML table is used for the layout of the web page. The image element is in a Table Cell. The image has the id, src, class, onclick and title attributes.

    For the CSS the body element is given the z-index value of 0. The image is given only the width and height values.

    Concerning the JavaScript, when the image is maximized, it is given the absolute position property and a higher z-index value. With this it appears bigger, covering any element it has to cover. There is the global variable “maximized,” which indicates whether the image is maximized or minimized. If the variable is “false,” the function “maximizeFn()” is called. If the value is “true” the function “restoreFn()” is called. The names of the functions and the lines in them are self-explanatory; as you read the lines, bear in mind all that I have said above.

    More HTML Articles
    More By Chrysanthus Forcha


       · Thanks for stopping by to read my article. If you have any comments, questions, or...
       · Hi, This article I would like if it had become with Ajax. I mean that if I have many...
       · Officially Ajax would download text or XML information. Officially Ajax would not...
     

    HTML ARTICLES

    - Comparing Browser Response to Active Client ...
    - Testing Browser Response to Active Client Pa...
    - Active Client Pages: Completing the Code for...
    - ACP and Browsers: Setting up an Example
    - How Browsers Respond to Active Client Pages
    - Completing a Tree with Active Client Pages
    - HTML Form Verification and ACP
    - Building an ACP Tree
    - Completing an ACP 3D HTML Table Image Gallery
    - Building an ACP 3D HTML Table Image Gallery
    - A Multiple Page Image Gallery with Active Cl...
    - Building an Image Gallery with Active Client...
    - Concluding a Menu for All Browsers
    - A Vertical Menu for All Browsers
    - Downloading Long HTML Pages with ACP







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek