473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

CSS Tabs - contents of a div disappear in IE & onclick is not working

rahulephp
CSS Tabs - contents of a div disappear in IE & onclick is not working

Here is the code:

Swaps the "active" tab and "inactive" tab and swaps out the new content via the display style attribute:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script type="text/javascript">

var active = 1;
var d = document;
function swapdiv(n) {
if (n != active) {
//tabs
d.getElementByid("l"+n).className = "active"
d.getElementByid("l"+active).className = "inactive";
//divs
d.getElementByid("d"+n).style.display = "block";
d.getElementByid("d"+active).style.display = "none";
//set active
active = n;
//even divs
evendivs();
}
}


function evendivs() {
var l = d.getElementByid("content");
var r = d.getElementByid("right");
//reset div heights
l.style.height = "";
r.style.height = "";
//check and resize divs as necessary
if (parseInt(l.offsetHeight) > parseInt(r.offsetHeight)) {
r.style.height = (parseInt(l.offsetHeight)+23)+"px";
} else if (parseInt(l.offsetHeight) < parseInt(r.offsetHeight)); {
l.style.height = (parseInt(r.offsetHeight)-27)+"px";
}
</script>
</head>

<body>


<div id="left">
<ul class="nav">
<li class="active" id="l1"><a onclick="swapdiv(1)">How this works</a></li>
<li class="inactive" id="l2"><a onclick="swapdiv(2)">About Us</a></li>
<li class="inactive" id="l3"><a onclick="swapdiv(3)">Testimonials</a></li>
<li class="inactive" id="l4"><a onclick="swapdiv(4)">Contact Us</a></li>
</ul>
<div class="clear">&nbsp;</div>
<div id="content">

<div id="d1" class="content"><h3>How it works</h3></div>
<div id="d2" class="content" style="display:none;"><h3>About US</h3></div>
<div id="d3" class="content" style="display:none;"><h3>Testimonials</h3></div>
<div id="d4" class="content" style="display:none;"><p>Contact Us Info</p></div>

</div>
</div>
</body>
</html>


Help me if you can find a solution regarding this.
Oct 31 '09 #1
1 4289
TheServant
1,168 Expert 1GB
Firstly, please wrap code in [code] tags.

Unfortunately issues in IE, are normally due to IE issues. As in, you should code so that it works in a real browser (like FF) and then make your IE tweaks later.

When you say "onclick is not working", do you mean in all browsers? Check if it's the html or javascript by replacing your onClick function from calling the other javascript function to:
Expand|Select|Wrap|Line Numbers
  1. onClick="(alert('This has fired!'))"
If that fires when you click, then your onClick is working. Then you need to make sure the javascript function swapdiv is working by putting the same little alert into the top of that function. Let us know how you go.
Nov 2 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: David List | last post by:
I'm having a problem using different properties of the document object in the example javascripts in my textbook with browsers that identify themselves as using the Mozilla engine. One example of...
2
by: mja674s | last post by:
I'm making a date picker. It shows up fine. The problem is that I want it to disappear if I click outside the calendar itself. However, if I click *on* the calendar itself, it should not...
0
by: Larry | last post by:
I have a problem where all of my Toolbar Tabs have disappeared in VS2003. I have reloaded VS and I still have no Toolbar Tabs. Does anyone know how to get the standard Toolbar Tabs back? I...
11
by: Steve B. | last post by:
How can I keep the ComboBox textbox empty of datasource items when my local application starts AND keep them empty even after the user clicks different Tabs on the form. I welcome any questions....
1
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
1
by: Ben | last post by:
Hi, I have a python script on a unix system that runs fine. I have a python script on a windows system that runs fine. Both use tabs to indent sections of the code. I now want to run them on the...
3
by: =?Utf-8?B?R3JlZyBN?= | last post by:
Hello, I'm running an asp.net, intranet web application using .net framework 1.1 on IIS5.1 / 6.0. Through the web application, I would like to press a button on the web page, have another window...
15
by: worked | last post by:
I have a script that hides / shows form elements, and wrapped in a tab script (tab navigation). When the code is duplicated (per tab content), the hide / show function works for the first tab but...
7
by: Andrew Poulos | last post by:
Is there a way for javascript to know if a browser has been set to open new windows in tabs? I'm trying to fix some code that allows a user to close a window that javascript opened and it seems to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.