SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2006
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple javascript prooves how useless IE is.

    Well either how usless ie is or how useless I am.

    This extremley simple code works fine in mozilla browsers and even safari I beliebe but it freezes IE, every time I click on one of these two links.

    <div style="float: left; background-color: #334f98; padding: 3px 7px; margin-left: 7px" id="o_tab">
    <a href="#" onClick="document.getElementById('manage').style.display='none'; document.getElementById('overview').style.display='block'; document.getElementById('o_tab').style.backgroundColor='#334f98'; document.getElementById('m_tab').style.backgroundColor='#adbbe0';" class="tab" ><span class="tab">Overview</span></a>
    </div>

    <div style="float: left; background-color: #adbbe0; padding: 3px 7px; margin-left: 7px" id="m_tab">
    <a href="#" onClick="document.getElementById('manage').style.display='block'; document.getElementById('overview').style.display='none'; document.getElementById('o_tab').style.backgroundColor='#adbbe0'; document.getElementById('m_tab').style.backgroundColor='#334f98';" class="tab" ><span class="tab">Manage</span></a>
    </div>

    Any help please? Thanks.

  2. #2
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,692
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    You'll want to make a function to do that you want. Also, in IE, you need to specify the initial display value for each element.

    Head section
    HTML Code:
    <script type="text/javascript">
      function toggleLinks(tabName,boxName) {
        document.getElementById("m_tab").style.backgroundColor = "#adbbe0";
        document.getElementById("o_tab").style.backgroundColor = "#adbbe0";
        document.getElementById("manage").style.display = "none";
        document.getElementById("overview").style.display = "none";
        document.getElementById(tabName).style.backgroundColor = "#334f98";
        document.getElementById(boxName).style.display = "block";
      }
    </script>
    Body section
    HTML Code:
    <div id="o_tab" style="background-color:#334f98"><a href="#" onclick="toggleLinks('o_tab','overview')">Overview</a></div>
    <div id="m_tab" style="background-color:#adbbe0"><a href="#" onclick="toggleLinks('m_tab','manage')">Manage</a></div>
    <div id="overview" style="display:block">Overview</div>
    <div id="manage" style="display:none">Manage</div>
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2006
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank a lot for taking the time to type the solution to my problem!

    I will try it out shortly.

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Location
    London, UK
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow! You've managed to find a fully reproducable IE bug that freezes the browser.
    Go to msdn.com and find somewhere to file the bug report. They'll be very pleased.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •