Username: Save?
Password:
Home Forum Links Search Login Register*
    News: Welcome to the TechnoWorldInc! Community!
Recent Updates
[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[February 14, 2024, 02:00:39 PM]
Subscriptions
Get Latest Tech Updates For Free!
Resources
   Travelikers
   Funistan
   PrettyGalz
   Techlap
   FreeThemes
   Videsta
   Glamistan
   BachatMela
   GlamGalz
   Techzug
   Vidsage
   Funzug
   WorldHostInc
   Funfani
   FilmyMama
   Uploaded.Tech
   MegaPixelShop
   Netens
   Funotic
   FreeJobsInc
   FilesPark
Participate in the fastest growing Technical Encyclopedia! This website is 100% Free. Please register or login using the login box above if you have already registered. You will need to be logged in to reply, make new topics and to access all the areas. Registration is free! Click Here To Register.
+ Techno World Inc - The Best Technical Encyclopedia Online! » Forum » THE TECHNO CLUB [ TECHNOWORLDINC.COM ] » Programming Zone » HTML
 Showing and Hiding HTML elements using Layers
Pages: [1]   Go Down
  Print  
Author Topic: Showing and Hiding HTML elements using Layers  (Read 905 times)
Daniel Franklin
TWI Hero
**********


Karma: 3
Offline Offline

Posts: 16647


View Profile Email
Showing and Hiding HTML elements using Layers
« Posted: September 26, 2007, 03:33:07 PM »




That technique uses layers and Cascading Style Sheet definitions, and I'm going to tell you here, how it is done. Nothing pyrotechnic, but it'll pay a way to more complex tasks.

First, the demo. I believe once you visually see it, you'll understand better what I'm trying to accomplish here. Given below is a link. If you take your cursor over the link, an image appears somewhere on the screen. By tweaking you can control the placements. You can see the demo, along with the online version of this article at:

http://www.bytesworth.com/learn/dhtml00001.asp

I've purposely made the image appear over a text area so that you don't think it is a simple rollover image effect. The image actually appears above the text.

Below lies the code that of the effect that appears above.

First the HTML part that defines the general link and the division that defines the placement of the image. Take note of the CSS definitions required to set the z-index and the "hide" attributes. Before testing the code, remember to remove the preceding dots that I have appended so that your email software doesn't read the code as some "process-able" content.


.Bring Your Cursor Here and See The Image .<div style="position: relative; z-index: 1; top: -60px; left: 30px; visibility: hidden" id="piccy"> .<img src="/graphics/contact.gif"> .</div>

After this comes the quintessential JavaScript that actually performs the act. In between I've inserted comments using the way they are used in JavaScript, that is, using //.

.<script language="javascript">

if (document.layers) { appear = 'show'; disappear = 'hide'; } else if (document.all) { appear = 'visible'; disappear = 'hidden'; }

// Both Netscape and IE handle layers differently, and have different // syntax for handling their behavior when it comes to handling layer // attributes. // So whereas IE uses 'show' and 'hide,' Netscape uses 'visible' and // 'hidden'. So we check and assign the appropriate values beforehand.

function showpic(picture) { var thispicture; if (document.layers) { thispicture = document.layers[picture]; } else if (document.all) { thispicture = document.all(picture).style; } thispicture.visibility=appear; }

function hidepic(picture) { var thispicture; if (document.layers) { thispicture = document.layers[picture]; } else if (document.all) { thispicture = document.all(picture).style; } thispicture.visibility=disappear; } .</script>

So this is how it works!

Articles Source - Free Articles

Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Copyright © 2006-2023 TechnoWorldInc.com. All Rights Reserved. Privacy Policy | Disclaimer
Page created in 0.19 seconds with 24 queries.