Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Browser Test

  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Location
    Maryland
    Posts
    468
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Browser Test

    I need a function that will display an alert if the user is not using Internet Explorer.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    if (document.all) {
    //IE
    }
    else {
    //not IE
    }

    Can you elaborate what exactly do you want to do?
    Last edited by glenngv; 02-09-2004 at 02:52 AM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    Regular Coder
    Join Date
    Jul 2003
    Location
    Massachusetts
    Posts
    472
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Might want to do:
    Code:
    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...

  • #4
    Regular Coder
    Join Date
    Jan 2004
    Location
    Maryland
    Posts
    468
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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; 02-09-2004 at 03:04 AM.

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    Regular Coder
    Join Date
    Jan 2004
    Location
    Maryland
    Posts
    468
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    innerText is only supported in IE. Use innerHTML instead.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #8
    Regular Coder
    Join Date
    Jan 2004
    Location
    Maryland
    Posts
    468
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #10
    Regular Coder
    Join Date
    Jan 2004
    Location
    Maryland
    Posts
    468
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm testing on firebird and IE what ever the latest one is.

  • #11
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Check the javascript console for any error message.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #12
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    isn't "clientInformation" serverside Jscript for Jscript.Net ASP implementation ... doesn't seem to work for me in IE

  • #13
    Regular Coder
    Join Date
    Jan 2004
    Location
    Maryland
    Posts
    468
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #14
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #15
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    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 <[lio@wg]>
    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


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •