www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 01-20-2007, 09:03 PM
    HiDeWaY HiDeWaY is offline
    Registered User
     
    Join Date: Aug 2003
    Posts: 6
    resolved IE issue with display: inline and position: absolute (solved) (Move to CSS section)

    I'm posting this in the javascript forum instead of the CSS forum because my guess is that this issue only has a real solution based on javascript. Please read before posting. Also, notice that I've only tested this application on FireFox and IE 7.0. I'll be needing to show all the HTML and Javascript in my page in order to expose the while problem, so I'll try explaining what's the logic behind the application so you won't be totaly in the blank about it.

    I'm currently coding a Javascript based window system for IE and browsers who follow the DOM specification (ex: FireFox). The application structure will be divided in three div areas:
    - List of tabs.
    -* This will list all available tabs, each containing it's own window area and list of windows.
    - Window Area.
    -* Each Window area will be able to have several windows.
    - List of windows (of a certain tab).
    -* Will list all windows in the selected tab.

    All the area's root are div elements named: Header, Body and Footer; and every content on them is dynamically generated using javascript as soon as the body's "onload" event fires. The called function is named: LoadGWS.

    Javascript overall explanation:
    PHP Code:
    -LoadGWS();
    --
    LoadHeadAndFooter(); // Generates header and footer text.
    --// Generates the body structure.
    --CreateTab("News"); // Generates the News's tab and it's Windows Area
    --CreateTab("Login"); // Generates the Login's tab and it's Windows Area
    --CreateTab("Register"); // Generates the Register's tab and it's Windows Area
    --CreateWindow("News",0,0,"full","full","TabId_1"); // Creates a window named "News" and attaches it to the News's tab (TabId_1).
    --SelectTab("TabId_1"); // Login's tab is now the active tab (none was before)
    --// Generates the window's list basic structure.
    I'm still in the beginning of this javascript version so the only functionalities that works are:
    - Creating a tab.
    - Selecting a tab.

    HTML structure: (after being generated by the javascript)
    PHP Code:
    <body onload="LoadGWS();">
      <
    div id="Header">
        <
    span id="Header_Title1">World Of Guirn</span>
        <
    br/>
        <
    span id="Header_Title2">The Five Kingdoms</span>
      </
    div>
      <
    div id="Body" style="height: 767px;">
        <
    div id="Body_TabArea">
          <
    span class="SelectedTab" id="TabId_1">News</span>
          <
    span class="Tab" id="TabId_2">Login</span>
          <
    span class="Tab" id="TabId_3">Register</span>
          <
    span class="Tab" id="TabId_4">New Tab</span>
          <
    a id="CreateTab" href="javascript: CreateTab('New Tab')">Create new tab</a>
        </
    div>
        <
    div id="Body_WindowArea" style="height: 726px;">
          <!--
    News (AreaId_1) is active -->
          <
    div id="AreaId_1" class="ActiveWindowArea" style="height: 726px;">
            <!--
    WindowDiv means that the div is position: absolute -->
            <
    div class="WindowDiv" style="top: 0px; left: 0px; width: 0px; height: 0px;">
              <
    div class="WindowTitleDiv">
                <
    span class="WindowTitle">News</span>
                <
    span class="WindowButtons"/>
              </
    div>
              <
    div class="WindowBodyDiv">body..</div>
            </
    div>
          </
    div>
          <
    div id="AreaId_2" class="WindowArea" style="height: 726px;"/>
          <
    div id="AreaId_3" class="WindowArea" style="height: 726px;"/>
          <
    div id="AreaId_4" class="WindowArea" style="height: 726px;"/>
        </
    div>
        <
    div id="Body_WindowList">
          <
    span id="WindowListLeftArrow"><</span>
          <
    span id="WindowListRightArrow">></span>
        </
    div>
      </
    div>
      <
    div id="Footer">
        <
    span id="Footer_Text">guirn.com - 2007</span>
      </
    div>
    </
    body>
    Now, about the issue. It appened with the include of the following CSS rules:
    PHP Code:
    // Notice that all Window's Areas are created with the WindowArea className
    .WindowArea { // className that affects all but the active Window Area
        
    display: none;
    }
    .
    ActiveWindowArea { // className that affects only the active Window Area
        
    display: inline;
    }
    .
    WindowDiv { // classname always active and affects all windows from all windows areas.
        
    position: absolute;
    }
    With these rules, the Window's DIV element, being child of the WindowArea will, or won't, be shown by the browser depending on the WindowArea's CSS display rule. It will show with display: inline, it will not be shown with display: none. This is what happens on FireFox. IE is giving me an headache for days now.

    Here is what I mean:
    PHP Code:
    CreateTab("News");
    CreateTab("Login");
    CreateTab("Register");
    // SelectTab("TabId_1"); /* (1)  display: inline; before creating the Window */
    CreateWindow("News",0,0,"full","full","TabId_1");
    SelectTab("TabId_1"); /* (2) display: inline; after creating the window*/
    alert(document.getElementById("TabId_1").WindowArea.childNodes[0].childNodes[0].childNodes[0].childNodes[0].data); // outputs the Window's title text showing tha the window still exists.
    Using (2), will produce the expected output on FireFox, but nothing will be shown on IE. The Window structure simply never appears. Later I used the alert to be sure that the window really exists. Using (1) instead of (2), will work on IE, but only until I change the active tab. After that the window structure will also disapear for good.

    I'm completely lost on why this appens, and my only guess is that IE doesn't apply the "display: inline" to it's "position: absolute" children? I've already tried several combinations of "display: inline" on the involved elements but nothing seems to work. Can someone help me solve this problem? I'll apreciate any suggestion.

    PS: I've attached the html file.
    Attached Files
    File Type: txt wog.htm.txt (7.7 KB, 22 views)

    Last edited by HiDeWaY; 01-21-2007 at 10:34 AM. Reason: Problem solved. :)
    Reply With Quote
      #2  
    Old 01-21-2007, 01:07 AM
    Kor's Avatar
    Kor Kor is offline
    Red Devil Moderator
     
    Join Date: Dec 2003
    Location: Bucharest, ROMANIA
    Posts: 11,522
    For the moment I see strange things in your code. It seems like you have not understood the end tag rules in XHTML.

    The slash <tag /> is used in XHTML to close only those tags which in HTML have no end tags (br, input, ...), but not those who have already native end tags (span, div,...)

    So that coding as: <div /> and <span /> is incorrect, as far as I know. Should be, as in HTML, <div></div> , <span></span>

    On the other hand, div is a native block-level displayed element, not an inline one, while span is an inline, not a block

    To align inline the same line block elements you should use the CSS float

    Last edited by Kor; 01-21-2007 at 01:10 AM.
    Reply With Quote
      #3  
    Old 01-21-2007, 10:32 AM
    HiDeWaY HiDeWaY is offline
    Registered User
     
    Join Date: Aug 2003
    Posts: 6
    resolved

    First of all, thanks a lot for your reply. It solved my problem.

    I was misguided on the display: inline description on www.w3schools.com wich states that display: inline is the default value. I knew that div is a block element but all I wanted to do was to reset the display to it's original value. Thanks a lot for noticing that.

    PS: The generated code it's just copy paste from FireBug. But thanks for stating that.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    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

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:10 AM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.