Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3393338
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:02:20+00:00 2026-05-18T04:02:20+00:00

So here is another z-index issue in IE7 I have ran into. I found

  • 0

So here is another z-index issue in IE7 I have ran into. I found an explanation of the problem else where but without a fix.

When you have a positioned element with an inline z-index of 0, javascript doesn’t return the correct z-index. If a z-index is set to the element in a stylesheet it will return that z-index instead. I get the same result using jQuery too.

Make an html file with the following:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
   $(function(){
      $('button').click(function(){
         alert($('#mainBox').css('zIndex'));
      });
   });
</script>
<style type="text/css">
   #mainWr {
      position: relative;
      z-index: 2;
      border: 1px solid #333;
      width: 200px;
      height: 200px;
   }
   #mainBox {
      z-index: 1;
      border: 1px solid #555;
      width: 100px;
      height: 100px;
      position: absolute;
      top: 50px;
      left: 50px;
   }

</style>

<div id="mainWr">
   <div id="mainBox" style="z-index: 0;"></div>
</div>
<br />
<button type="button">Show #mainBox z-index</button>

Open that in IE7. The problem does not exist in IE8.

I jsfiddled it if you have IE7, otherwise you will need to use the code and display it with whatever method you use to emulate IE7:

http://jsfiddle.net/dalelarsen/DndnM/

I am not aware of any solutions. Any comments are welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:02:21+00:00Added an answer on May 18, 2026 at 4:02 am

    Okay, I solved this. The solution is to make sure you grab exactly what is inline yourself and don’t rely on the browser.

    So I wrote a small object (as a jquery plugin) that parses what is in the element’s style attribute and returns the correct value. I am using this for getting the z-index but I wrote it to return any style. You have to pass in the style being requested using the real css name of the style, e.g. ‘z-index’ instead of ‘zIndex’. Maybe at some later day I will rewrite it to account for camel case.

    Anyway, here it is:

    jQuery.fn.inlineStyle = function(stylesName){
    
       var allStyles = this.attr('style');
    
       var allStylesArr = allStyles.split(';');
       var allStylesObj = {};
       for (var i = 0; i < allStylesArr.length; i++) {
          var parts = allStylesArr[i].split(':');
          allStylesObj[$.trim(parts[0]).toLowerCase()] = $.trim(parts[1]);
       }
       var rStyleVal = false;
       if (allStylesObj[stylesName]) rStyleVal = allStylesObj[stylesName];
       return rStyleVal;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our team just ran into the same issue described here http://forums.codeguru.com/archive/index.php/t-514404.html , i.e. calling
Hi i have issue here of calling another controller action to send an mail,
Here is the issue: I have a page index.php and onclick of select element
I have run into another problem in relation to a site I am trying
Here's another one for you to help me solve: I have an ASP.NET website
So here's another IE cross-compatibility issue. My website, www.zerozaku.com, is compatible with Chrome and
I must be retarded with searching, because here's another seemingly common problem that I
here is my problem. I have a class A that has a string of
I've got a similar issue to that reported by another user here XAMPP v1.7.4
My issue can be seen here: http://jasonnarciso.com/dev/cmwd/concrete-solutions/ Basically I have a very simple jquery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.