I need a function that will display an alert if the user is not using Internet Explorer.
Announcement
Collapse
No announcement yet.
Browser Test
Collapse
X
-
Might want to do:Code:if(typeof clientInformation != 'undefined') { // success } else { // fail }
Moderator @ WebDeveloper.com
Mentor @ WebXpertz.net
Comment
-
Basicly I made a page to do mol conversions for chemistry, but it only works in IE. This is probably due to the fact that I'm new to javascript so it's messy. But I want an alert saying the page will only work in IE. Thanks for the code. I should be able to get what I want out of that. I think.......
Edit: Thanks I got it working.Last edited by squirellplaying; Feb 8, 2004, 11:04 PM.
Comment
-
mol conversion is just about math and there seems to be no reason to make it worked in IE only. Maybe you referenced the field names by specifying their names only?
var x = fieldNameHere.value;
This works in IE because IE makes the field names and ids as global objects.
Please correct me if I was wrong in my assumption.
Comment
-
That is basicly what I did. But even my main page which has no math on it does not work. I did
var fMolW = document.getElementById('blah').value
Code:<html> <head> <style> span{ text-align:right; color:black; font-weight:bold; } </style> <title>Chem</title> <link rel="stylesheet" type="text/css" href="style.css"/> </head> <body> <div id="findRepParticles"> <span id="input"> <form> Mass of G<input type="textbox" value="0" id="massG"/> <br /> Molar Mass of G<input type="textbox" value="0" id="molarMassG"/> <br /> Number of moles of W<input type="textbox" value="0" id="molW" /> <br /> Number of moles of G<input type="textbox" value="0" id="molG" /> <br /> <input type="button" value="Get the answer!" onclick="findMassW()" /> <br /> </form> </span> <span id="answers"> <br /> Moles of G:<span id="molOfGanswer"></span> <br /> Moles of W:<span id="molOfWanswer"></span> <br /> Representative Particles of W:<span id="repPartsOfWanswer"></span> </span> <script> function findMassW(){ var iG = document.getElementById('massG').value; var fAvogadro = "6.02E23"; var fMolarMass = document.getElementById('molarMassG').value; var fMolW = document.getElementById('molW').value; var fMolG = document.getElementById('molG').value; document.getElementById('molOfGanswer').innerText=parseFloat(iG)/parseFloat(fMolarMass) document.getElementById('molOfWanswer').innerText=parseFloat(iG)/parseFloat(fMolarMass)*parseFloat(fMolW)/parseFloat(fMolG) document.getElementById('repPartsOfWanswer').innerText=parseFloat(iG)/parseFloat(fMolarMass)*parseFloat(fMolW)/parseFloat(fMolG)*parseFloat(fAvogadro) } </script> </div> </body> </html>
I know this isn't the cleanest code. But I'm still learning Jscript.
Comment
-
Comment
-
It works for me in Netscape7 and Mozilla 1.0. Although the fields are aligned to the right. But as far as functionality is concerned, it works. Don't tell me you're testing it with Netscape4.x or other extinct browsers. document.getElementById does not work on them at all.
Comment
-
-
It means that the id "molOfGAnswer" does not exist. Check the spelling and case.
Though I didn't see any case or spelling error in the code you posted above. I just changed innerText to innerHTML and it worked for me.
Comment
-
window.clientInformation is an iew only property providing the same information as window.navigator (maybe with some additions). Does not exist in iem, I believe.liorean <[[email protected]]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
Comment
Comment