Web Analytics Made Easy -
StatCounter Browser Test - CodingForum

Announcement

Collapse
No announcement yet.

Browser Test

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Browser Test

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

  • #2
    if (document.all) {
    //IE
    }
    else {
    //not IE
    }

    Can you elaborate what exactly do you want to do?
    Last edited by glenngv; Feb 8, 2004, 09:52 PM.
    Glenn
    vBulletin Mods That Rock!

    Comment


    • #3
      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...
      Moderator @ WebDeveloper.com
      Mentor @ WebXpertz.net

      Comment


      • #4
        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, 10:04 PM.

        Comment


        • #5
          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
          vBulletin Mods That Rock!

          Comment


          • #6
            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


            • #7
              innerText is only supported in IE. Use innerHTML instead.
              Glenn
              vBulletin Mods That Rock!

              Comment


              • #8
                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.

                Comment


                • #9
                  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
                  vBulletin Mods That Rock!

                  Comment


                  • #10
                    I'm testing on firebird and IE what ever the latest one is.

                    Comment


                    • #11
                      Check the javascript console for any error message.
                      Glenn
                      vBulletin Mods That Rock!

                      Comment


                      • #12
                        isn't "clientInformation" serverside Jscript for Jscript.Net ASP implementation ... doesn't seem to work for me in IE
                        *keep it simple (TM)

                        Comment


                        • #13
                          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.

                          Comment


                          • #14
                            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
                            vBulletin Mods That Rock!

                            Comment


                            • #15
                              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

                              Working...
                              X