473,586 Members | 2,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

rahulephp
59 New Member
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.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitl ed Document</title>

<script type="text/javascript">

var active = 1;
var d = document;
function swapdiv(n) {
if (n != active) {
//tabs
d.getElementByi d("l"+n).classN ame = "active"
d.getElementByi d("l"+active).c lassName = "inactive";
//divs
d.getElementByi d("d"+n).style. display = "block";
d.getElementByi d("d"+active).s tyle.display = "none";
//set active
active = n;
//even divs
evendivs();
}
}


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

<body>


<div id="left">
<ul class="nav">
<li class="active" id="l1"><a onclick="swapdi v(1)">How this works</a></li>
<li class="inactive " id="l2"><a onclick="swapdi v(2)">About Us</a></li>
<li class="inactive " id="l3"><a onclick="swapdi v(3)">Testimoni als</a></li>
<li class="inactive " id="l4"><a onclick="swapdi v(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>Abou t US</h3></div>
<div id="d3" class="content" style="display: none;"><h3>Test imonials</h3></div>
<div id="d4" class="content" style="display: none;"><p>Conta ct Us Info</p></div>

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


Help me if you can find a solution regarding this.
Oct 31 '09 #1
1 4305
TheServant
1,168 Recognized Expert Top Contributor
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
6829
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 these problems is using document.layers. I have Google'd for examples of how to use the document object specifically with Mozilla, but I cannot find...
2
2897
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 disappear, allowing me to click a date or cycle through the months, etc. Thanks for help. Matt
0
1111
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 hope that I don't have to manually build them.
11
2283
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. The problem isn’t clearing the items from the CB textbox, the problem is I can’t keep them empty when the user moves around the Tabs on the...
1
6495
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 java class which creates a xml file based on values entered in dynamic jsp page. Now i want to read all those values entered to xml in my other jsp...
1
295
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 same system, actually in the same script by combining bits and pieces. But whatever I try my windows tabs get converted to spaces when I transfer...
3
2779
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 (not web-based or part of current application) brought to the front and focused (findwindow api) and have the button scrape the contents of the...
15
3795
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 breaks in each subsequent tab. Why? Help appreciated! Example: http://geocities.com/edmurphy21/ hide / show script: <script...
7
3016
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 get confused what window to close when a new tab is opened. (The user clicks a link in the opened window which which opens a new window and close...
0
7915
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7841
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7965
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3838
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1184
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.