I'm creating a webpage that has an Iframe and a drop down menu to change the contents of Iframe when the link is changed. I don't know very much javascript because I'm just starting to learn it. It works perfectly in Internet Explorer(no error messages), but in Mozilla FireFox the menu pops down, but the Iframe is not displayed, or change. If I put http://www.google.com as the src it will display but will not change. It says "moles" is not defined. I looked through my code and could not find a non defined "moles". Help!
Line 73:
Sorry for posting the whole code but I do not know where my error is.
Error: moles is not defined
Source File: file:///C:/Documents%20and%20Settings/Dave/Desktop/Mol/Index.html
Line: 73
Source File: file:///C:/Documents%20and%20Settings/Dave/Desktop/Mol/Index.html
Line: 73
divX = eval(x);
Code:
<html> <head> <script> if(typeof clientInformation != 'undefined') { // success } else { alert('This page only works in Microsoft Internet Explorer. Please reload this page using Internet Explorer. Sorry for the innconvience.')// fail } </script> <style> td{ border:2px solid silver; } #showMoleConversions{ text-align:center; font-family:Tahoma; border-bottom:solid black 1px; } #moles{ position:absolute; top:24px; font-family:NewZurica; height:10px; border-bottom:solid black 1px; } #repParts{ position:absolute; top:48px; font-family:NewZurica; height:10px; border-bottom:solid black 1px; } #mass{ position:absolute; top:48px; font-family:NewZurica; height:10px; border-bottom:solid black 1px; } #volume{ position:absolute; top:48px; font-family:NewZurica; height:10px; border-bottom:solid black 1px; } </style> <title>Mol Conversions</title> <script language="javascript"> // *****Test for IE***** function showdiv(x) { var divX; divX = eval(x); if (divX.style.visibility == "hidden") { divX.style.visibility = "visible" } else { divX.style.visibility = "hidden" } } // *****End Test for IE***** // *****Source Changing***** function changeToRep(){ document.getElementById('main').src="MassToRep.html" } function changeToVolume(){ document.getElementById('main').src="MassToVolume.html" } function changeToMass(){ document.getElementById('main').src="MassToMass.html" } function changeToRep(){ document.getElementById('main').src="VolumeToRep.html" } function changeToVolume(){ document.getElementById('main').src="VolumeToVolume.html" } function changeToMass(){ document.getElementById('main').src="VolumeToMass.html" } function changeToRep(){ document.getElementById('main').src="RepToRep.html" } function changeToVolume(){ document.getElementById('main').src="RepToVolume.html" } function changeToMass(){ document.getElementById('main').src="RepToMass.html" } </script> </head> <body topmargin="0" style="background-color:dimgray"> <!--****************************Change the Conversions****************************************--> <table style="width:100%; background-color:tan"> <tr> <td id="showMoleConversions" onclick="showdiv('moles');getElementById('mass').style.visibility='hidden';getElementById('volume').style.visibility='hidden';getElementById('repParts').style.visibility='hidden'">Mole Conversions</td> <tr> </table> <!--****************************Change the Links*********************************************--> <div id="moles" style="visibility:hidden"> <table style="width:100%; background-color:green""> <tr> <td style="text-align:center; width:33%" onclick="showdiv('repParts');getElementById('mass').style.visibility='hidden';getElementById('volume').style.visibility='hidden'">Representative Particles</td> <td style="text-align:center; width:33%" onclick="showdiv('mass');getElementById('repParts').style.visibility='hidden';getElementById('volume').style.visibility='hidden'">Mass</td> <td style="text-align:center; width:33%" onclick="showdiv('volume');getElementById('repParts').style.visibility='hidden';getElementById('mass').style.visibility='hidden'">Volume</td> </tr> </table> </div> <!--****************************Change the Iframe*********************************************--> <div id="repParts" style="visibility:hidden"> <table style="width:100%; background-color:black; color:white;"> <tr> <td style="text-align:center; width:33%" onclick="changeToRep()">To Representative Particles</td> <td style="text-align:center; width:33%" onclick="changeToMass()">To Mass</td> <td style="text-align:center; width:33%" onclick="changeToVolume()">To Volume</td> </tr> </table> </div> <div id="mass" style="visibility:hidden"> <table style="width:100%; background-color:blue"> <tr> <td style="text-align:center; width:33%" onclick="changeToRep()">To Representative Particles</td> <td style="text-align:center; width:33%" onclick="changeToMass()">To Mass</td> <td style="text-align:center; width:33%" onclick="changeToVolume()">To Volume</td> </tr> </table> </div> <div id="volume" style="visibility:hidden"> <table style="width:100%; background-color:red"> <tr> <td style="text-align:center; width:33%" onclick="changeToRep()">To Representative Particles</td> <td style="text-align:center; width:33%" onclick="changeToMass()">To Mass</td> <td style="text-align:center; width:33%" onclick="changeToVolume()">To Volume</td> </tr> </table> </div> <!--***********************************Iframe*************************************************--> <iframe id="main" src="blank.html" style="position:absolute; top:80; width:100%; height:100%; border:none 0 white"> Not supported by your browser </iframe> <!--***********************************Information********************************************--> <br /> <span style="position:absolute; top:575;"> Calculator! Used to find molar Mass and do other simple calculations. If you do not fill up all the boxes leave as "0".<br /> <form> <input type="textbox" value="0" id="a" /> + <input type="textbox" value="0" id="b" /> + <input type="textbox" value="0" id="c" /> + <input type="textbox" value="0" id="d" /> + <input type="textbox" value="0" id="e" /> + <input type="textbox" value="0" id="f" /> + <input type="textbox" value="0" id="g" /> + <input type="textbox" value="0" id="h" /> + <input type="textbox" value="0" id="i" /> + <input type="textbox" value="0" id="j" /> = <span id="mathAnswer" style="color:red"></span> <br /> <input type="button" value="Find the answer" onclick="doSomeMath()" /> </form> </span> <script language="javascript"> function doSomeMath(){ var a=document.getElementById('a').value; var b=document.getElementById('b').value; var c=document.getElementById('c').value; var d=document.getElementById('d').value; var e=document.getElementById('e').value; var f=document.getElementById('f').value; var g=document.getElementById('g').value; var h=document.getElementById('h').value; var i=document.getElementById('i').value; var j=document.getElementById('j').value; document.getElementById('mathAnswer').innerHTML=parseFloat(a)+parseFloat(b)+parseFloat(c)+parseFloat(d)+parseFloat(e)+parseFloat(f)+parseFloat(g)+parseFloat(h)+parseFloat(i)+parseFloat(j); } </script> </body> </html>
Comment