JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 24th, 2004, 03:08 PM
browni browni is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Vicksburg, MS
Posts: 1 browni User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Dynamically updating the zindex of an object

I realize that this should be simple, but I'm stumped.

I have two images on a page. I've used CSS and absolute positioning to
position the images so that one partially obscures the other. One image
has a zIndex of 3, the other 4.

I need to have an onmouseover event for the rear image which increases
its zIndex so that it moves in front of the front image. I also want to
switch this back onMouseOut.

Here is the function I'm working with________________________
function setZ(id, z) {
var IE4 = (document.all) ? true : false;
var NS4 = (document.layers) ? true : false;
if (IE4)
{eval("document.all." + id).style.zIndex = z;}
else
{eval ("document." + id).zIndex = z;}
}

Here are the relevant CSS styles___________________________
#firstImg {position: absolute; z-index: 3; left: 160px; top: 170px;}
#secondImg {position: absolute; z-index: 4; left: 307px; top: 281px;}

Here is the HTML________________________________________
<img id="firstImg" name="firstImg" src="images/front_small.jpg"
onmouseover="setZ('firstImg',10)"
onmouseout="setZ('firstImg',3)" >

<img id="secondImg" name="secondImg" src="images/back_small.jpg">



This works perfectly fine in IE, but no matter what I've tried, I can't make
it work in NN.

I would greatly appreciate it if anyone has the solution for this.

Thanks,
browni

Reply With Quote
  #2  
Old July 1st, 2006, 12:52 AM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 473 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 19 m 14 sec
Reputation Power: 3
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
all you have to do is use this coding...

window.document.object.style.z-index=0;
or
window.document.all.divlayer.style.z-index=0;

hope this helped

colton22

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Dynamically updating the zindex of an object


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT