August 19, 2009

Javascript 16: Math Objects & Browser Informations


document.write(Math.round(3.141596566494));


This will be rounded to 3 as a whole number. If you put in 3.5, then it will be rounded to 4. If you put


document.write(Math.round(-5.6464549454));

The number will be put into -6. If you put in the parenthesis inside of random, then it will show up a random long digit number.

Browser Information


var test=navigator.appName;
document.write("You are using "+test);


This will show up your Browser's name. If you are using Mozilla, it will say Netscape instead.


document.write("You are using "+navigator.appName);

Now I deleted the variable and used the Javascript object. naviagator.appName
This will result the same way. Even if you change the object name to navigator.appName to naviagator.platform, then it will show up your platform name, most likely Win32.



document.write("You are using "+navigator.platform);




, , , , ,



Powered by ScribeFire.

No comments:

Post a Comment