Hi there! I hope someone can help me out with this. I am trying to include a small section on my webpage that has 4 different tabs. When the user clicks on tab 1, they get the information related to tab 1. When they click on tab 2, the informaiton changes to that related to tab 2, and so on. I am using a combination of CSS and Javascript. It is working as I need it in IE, but I can’t get it to work in FireFox. I am not very familiar with JS, so I’m not sure if I am missing something in the JS file or the CSS file.
Here is a link to the testing page: [URL=”http://www.aahahealthypet.com/tab_testing.html”]http://www.aahahealthypet.com/tab_testing.html
Could someone please take a look and help me figure out what I am missing to get this to work in FireFox? I am totally stumped and it’s probably something that is staring me right in the face!
Thank you!!!!!
<i>
</i>function init(){
tabContents.innerHTML = t1Contents.innerHTML;
}
<i>
</i>function init(){
document.getElementById("tabContents").innerHTML =document.getElementById("t1Contents").innerHTML;
}
[CODE]
//a public function that the container uses to pass in values for the labels
function public_Labels(label1, label2, label3, label4){
document.getElementById("t1").innerText = label1;
// t1.innerText = label1;
document.getElementById("t2").innerText = label2;
// t2.innerText = label2;
document.getElementById("t3").innerText = label3;
// t3.innerText = label3;
document.getElementById("t4").innerText = label4;
// t4.innerText = label4;
}
//a public function that the container uses to pass in values for the card containers
function public_Contents(contents1, contents2, contents3, contents4){
document.getElementById("t1Contents").innerHTML = contents1;
// t1Contents.innerHTML = contents1;
document.getElementById("t2Contents").innerHTML = contents2;
// t2Contents.innerHTML = contents2;
document.getElementById("t3Contents").innerHTML = contents3;
// t3Contents.innerHTML = contents3;
document.getElementById("t3Contents").innerHTML = contents3;
// t4Contents.innerHTML = contents4;
init();
}
//sets the default display to tab 1
//function init(){
// tabContents.innerHTML = t1Contents.innerHTML;
//}
function init(){
document.getElementById("tabContents").innerHTML =document.getElementById("t1Contents").innerHTML;
}
//this is the tab switching function
var currentTab;
var tabBase;
var firstFlag = true;
function changeTabs(){
if(firstFlag == true){
document.getElementById("currentTab") = document.getElementById("t1");
document.getElementById("tabBase") = document.getElementById("t1base");
firstFlag = false;
}
if(window.event.srcElement.className == "tab"){
document.getElementById("currentTab").className = "tab";
// currentTab.className = "tab";
document.getElementById("tabBase").style.backgroundColor = "white";
// tabBase.style.backgroundColor = "white";
document.getElementById("currentTab") = window.event.srcElement;
// currentTab = window.event.srcElement;
document.getElementById("tabBaseID") = currentTab.id + "base";
// tabBaseID = currentTab.id + "base";
document.getElementById("tabContentID") = currentTab.id + "Contents";
// tabContentID = currentTab.id + "Contents";
document.getElementById("tabBase") = document.all(tabBaseID);
// tabBase = document.all(tabBaseID);
document.getElementById("tabContent") = document.all(tabContentID);
// tabContent = document.all(tabContentID);
document.getElementById("currentTab.className") = "selTab";
// currentTab.className = "selTab";
document.getElementById("tabBase").style.backgroundColor = "";
// tabBase.style.backgroundColor = "";
document.getElementById("tabContents").innerHTML = document.getElementById("tabContent").innerHTML;
// tabContents.innerHTML = tabContent.innerHTML;
}
}
[/CODE]
[CODE]//a public function that the container uses to pass in values for the labels
function public_Labels(label1, label2, label3, label4){
document.getElementById("t1").innerText = label1;
document.getElementById("t2").innerText = label2;
document.getElementById("t3").innerText = label3;
document.getElementById("t4").innerText = label4;
}
//a public function that the container uses to pass in values for the card containers
function public_Contents(contents1, contents2, contents3, contents4){
document.getElementById("t1Contents").innerHTML = contents1;
document.getElementById("t2Contents").innerHTML = contents2;
document.getElementById("t3Contents").innerHTML = contents3;
document.getElementById("t3Contents").innerHTML = contents3;
init();
}
//sets the default display to tab 1
function init(){
document.getElementById("tabContents").innerHTML =document.getElementById("t1Contents").innerHTML;
}
//this is the tab switching function
var currentTab;
var tabBase;
var firstFlag = true;
function changeTabs(){
if(firstFlag == true){
currentTab = t1;
tabBase = t1base;
firstFlag = false;
}
if(window.event.srcElement.className == "tab"){
currentTab.className = "tab";
tabBase.style.backgroundColor = "";
currentTab = window.event.srcElement;
tabBaseID = currentTab.id + "base";
tabContentID = currentTab.id + "Contents";
tabBase = document.all(tabBaseID);
tabContent = document.all(tabContentID);
currentTab.className = "selTab";
tabBase.style.backgroundColor = "";
document.getElementById("tabContents").innerHTML = tabContent.innerHTML;
}
}
[/CODE]
if(firstFlag == true){
currentTab = t1;
tabBase = t1base;
firstFlag = false;
}
<i>
</i> if(firstFlag == true){
currentTab = document.getElementById("t1");
tabBase = document.getElementById("t1base");
firstFlag = false;
}
[CODE]//a public function that the container uses to pass in values for the labels
function public_Labels(label1, label2, label3, label4){
document.getElementById("t1").innerText = label1;
document.getElementById("t2").innerText = label2;
document.getElementById("t3").innerText = label3;
document.getElementById("t4").innerText = label4;
}
//a public function that the container uses to pass in values for the card containers
function public_Contents(contents1, contents2, contents3, contents4){
document.getElementById("t1Contents").innerHTML = contents1;
document.getElementById("t2Contents").innerHTML = contents2;
document.getElementById("t3Contents").innerHTML = contents3;
document.getElementById("t3Contents").innerHTML = contents3;
init();
}
//sets the default display to tab 1
function init(){
document.getElementById("tabContents").innerHTML =document.getElementById("t1Contents").innerHTML;
}
//this is the tab switching function
var currentTab;
var tabBase;
var firstFlag = true;
function changeTabs(){
if(firstFlag == true){
currentTab = document.getElementById("t1");
tabBase = document.getElementById("t1base");
firstFlag = false;
}
if(window.event.srcElement.className == "tab"){
currentTab.className = "tab";
tabBase.style.backgroundColor = "";
currentTab = window.event.srcElement;
tabBaseID = currentTab.id + "base";
tabContentID = currentTab.id + "Contents";
tabBase = document.all(tabBaseID);
tabContent = document.all(tabContentID);
currentTab.className = "selTab";
tabBase.style.backgroundColor = "";
document.getElementById("tabContents").innerHTML = tabContent.innerHTML;
}
}
[/CODE]
<i>
</i>function changeTabs(){
<i> </i>if(firstFlag == true){
<i> </i> currentTab = document.getElementById("t1");
<i> </i> tabBase = document.getElementById("t1base");
<i> </i> firstFlag = false;
<i> </i>}
<i> </i>if(window.event.srcElement.className == "tab"){
<i>
</i>function changeTabs(evt){
if(window.event) evt=window.event;
<i> </i>if(firstFlag == true){
<i> </i> currentTab = document.getElementById("t1");
<i> </i> tabBase = document.getElementById("t1base");
<i> </i> firstFlag = false;
<i> </i>}
<i> </i>if(evt.srcElement.className == "tab"){
[CODE]//a public function that the container uses to pass in values for the labels
function public_Labels(label1, label2, label3, label4){
document.getElementById("t1").innerText = label1;
document.getElementById("t2").innerText = label2;
document.getElementById("t3").innerText = label3;
document.getElementById("t4").innerText = label4;
}
//a public function that the container uses to pass in values for the card containers
function public_Contents(contents1, contents2, contents3, contents4){
document.getElementById("t1Contents").innerHTML = contents1;
document.getElementById("t2Contents").innerHTML = contents2;
document.getElementById("t3Contents").innerHTML = contents3;
document.getElementById("t3Contents").innerHTML = contents3;
init();
}
//sets the default display to tab 1
function init(){
document.getElementById("tabContents").innerHTML =document.getElementById("t1Contents").innerHTML;
}
//this is the tab switching function
var currentTab;
var tabBase;
var firstFlag = true;
function changeTabs(evt){
if(window.event) evt=window.event;
if(firstFlag == true)
{
currentTab = document.getElementById("t1");
tabBase = document.getElementById("t1base");
firstFlag = false;
}
if(evt.srcElement.className == "tab"){
currentTab.className = "tab";
tabBase.style.backgroundColor = "";
currentTab = window.event.srcElement;
tabBaseID = currentTab.id + "base";
tabContentID = currentTab.id + "Contents";
tabBase = document.all(tabBaseID);
tabContent = document.all(tabContentID);
currentTab.className = "selTab";
tabBase.style.backgroundColor = "";
document.getElementById("tabContents").innerHTML = tabContent.innerHTML;
}
}[/CODE]
<i>
</i>if(window.attachEvent)
window.attachEvent("onload", init);
else
window.addEventListener("load", init, false);
<i> </i>//a public function that the container uses to pass in values for the labels
function public_Labels(label1, label2, label3, label4){
<i> </i>document.getElementById("t1").innerText = label1;
<i> </i>document.getElementById("t2").innerText = label2;
<i> </i>document.getElementById("t3").innerText = label3;
<i> </i>document.getElementById("t4").innerText = label4;
}
//a public function that the container uses to pass in values for the card containers
function public_Contents(contents1, contents2, contents3, contents4){
<i> </i>document.getElementById("t1Contents").innerHTML = contents1;
<i> </i>document.getElementById("t2Contents").innerHTML = contents2;
<i> </i>document.getElementById("t3Contents").innerHTML = contents3;
<i> </i>document.getElementById("t3Contents").innerHTML = contents3;
<i> </i>init();
}
//sets the default display to tab 1
function init(){
document.getElementById("tabContents").innerHTML =document.getElementById("t1Contents").innerHTML;
}
//this is the tab switching function
var currentTab;
var tabBase;
var firstFlag = true;
function changeTabs(evt){
if(window.event) {
evt=window.event;
evt.target = window.event.srcElement;
}
<i> </i>if(firstFlag == true)
<i> </i>{
<i> </i> currentTab = document.getElementById("t1");
<i> </i> tabBase = document.getElementById("t1base");
<i> </i> firstFlag = false;
<i> </i>}
<i> </i>if(evt.target.className == "tab"){
<i> </i> currentTab.className = "tab";
<i> </i> tabBase.style.backgroundColor = "";
<i> </i> currentTab = evt.target;
<i> </i> tabBaseID = currentTab.id + "base";
<i> </i> tabContentID = currentTab.id + "Contents";
<i> </i> tabBase = document.getElementById(tabBaseID);
<i> </i> tabContent = document.getElementById(tabContentID);
<i> </i> currentTab.className = "selTab";
<i> </i> tabBase.style.backgroundColor = "";
<i> </i> document.getElementById("tabContents").innerHTML = tabContent.innerHTML;
<i> </i>}
}
</script>
[code=html]
<body>
<div onclick="changeTabs(event)" id="content_main">
[/code]
0.1.9 — BETA 5.2