...

View Full Version : Browser Test



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

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

Can you elaborate what exactly do you want to do?

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

else
{
// 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...

squirellplaying
02-09-2004, 03: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.

glenngv
02-09-2004, 03: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.

squirellplaying
02-10-2004, 08: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



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

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

squirellplaying
02-11-2004, 02: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.

glenngv
02-11-2004, 03: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.

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

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

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

squirellplaying
02-12-2004, 09: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.

glenngv
02-13-2004, 12: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.

liorean
02-13-2004, 12: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.

squirellplaying
02-13-2004, 04: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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum