/    Sign up×
Community /Pin to ProfileBookmark

Need a snippet to progress Z index

Hello!

I’m a javascript virgin, I’ve been blitzing basic HTML and i’ve finally progressed from Frames and tables to Divs and Layers and CSS… Thank God for that!

I’m a wee bit stuck now though. I want to use JS to toggle the Z index of my layers. This will is to avoid multiple reloads of the graphics and NavBars etc.

Can anyone point me to some JS that can do this?

Thank you, Fantastic Site this!

Warren

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 15.2006 — The elements must be positioned for it to work!
obj.style.zIndex=1000; // 0 bottom layer, higher values above (avoid -ve values)
Copy linkTweet thisAlerts:
@WarrenSauthorApr 15.2006 — I think I may have understated how much of a JS virgin I am... So i didnt know how to implement the script you gave me. But I used your help to find a snippet on another site,

http://www.dhtmlshock.com/layer-effects/LayerToFront/default.asp

Code below:

<script language="JavaScript1.2">

/*

Layer on Top

Copyright Massimo Foti (www.massimocorner.com)

To add more shock to your site, visit www.DHTML Shock.com

*
/

function tmt_DivOnTop(theDiv){

var t = 0;var z = (document.layers) ? ".zIndex" : ".style.zIndex";

var fun = (document.getElementById) ? "document.getElementById" : "MM_findObj";

var arr = (document.layers) ? document.layers : (document.all) ? document.all.tags("DIV") : document.getElementsByTagName("DIV");

for(var i=0;i<arr.length;i++){var oz = eval("arr["+i+"]"+z);if(oz > t){t = oz;}}

var obj = eval(fun+"(theDiv)");if(obj)eval(fun+"('"+theDiv+"')"+z+"=parseInt("+t+")+1");

}

</script>

<a href="javascript:;" onClick="tmt_DivOnTop('Black')">Link</a>

This worked really well using the links to raise a layer to to the front.

The next problem is to find a way to do previous and next commands on layers. I think the links will have to embedded in to each layer.

And the beat goes on.

Thanks for the help!

Warren
×

Success!

Help @WarrenS spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...