View Full Version : Browser Test

02-09-2004, 03:31 AM
I need a function that will display an alert if the user is not using Internet Explorer.

02-09-2004, 03:49 AM
if (document.all) {
else {
//not IE

Can you elaborate what exactly do you want to do?

02-09-2004, 03:58 AM
Might want to do:
if(typeof clientInformation != 'undefined')
// success

// fail
}Since document.all also exsits under Opera. I believe clientInformation only exists under IE; and, if you're wondering, it's exactly the same as the navigator object...

02-09-2004, 04:00 AM
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.

02-09-2004, 04:43 AM
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. :rolleyes:

Please correct me if I was wrong in my assumption.

02-10-2004, 09:42 PM
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


<link rel="stylesheet" type="text/css" href="style.css"/>

<div id="findRepParticles">

<span id="input">

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 />


<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>

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;

I know this isn't the cleanest code. But I'm still learning Jscript.

02-11-2004, 03:05 AM
innerText is only supported in IE. Use innerHTML instead.

02-11-2004, 03:13 AM
I changed them all and tested, and it still only works in IE. You don't have to edit the code for me, unless you have the time. I'm sure as I learn more Javascript I'll find my errors, but this will only be used on a few computers so it shouldn't be a big deal.

02-11-2004, 04:29 AM
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.

02-11-2004, 08:51 PM
I'm testing on firebird and IE what ever the latest one is.

02-12-2004, 06:47 AM
Check the javascript console for any error message.

02-12-2004, 03:26 PM
isn't "clientInformation" serverside Jscript for Jscript.Net ASP implementation ... doesn't seem to work for me in IE

02-12-2004, 10:57 PM
Error: document.getElementById("molOfGAnswer") has no properties
Source File: file:///C:/Documents%20and%20Settings/Dave/Desktop/Mol/VolumeToRep.html
Line: 46

I get that. It doesn't make sence.

02-13-2004, 01:52 AM
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.

02-13-2004, 01:59 AM
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.

02-13-2004, 05:29 AM
Alright. I did find my errors. Now just to fix it in 9 other pages. :(. But still need to fix the home page. I'm going to rewrite it and see if it fixes.