<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Mobile-Web-App: Javascript Exercise - number arithmetic, toFixed() and toPrecision()</title>
<script>
function test(){
var a = 10.1;
var b = 10.2;
var c = a + b;
info = "<p>a = 10.1, b = 10.2, c = a + b</p>"
+ "<p> a + b = " + (a + b) + "</p>"
+ "<p> c = " + c + "</p>"
+ "<p> c.toFixed(2) = " + c.toFixed(2) + "</p>"
+ "<p> c.toPrecision(8) = " + c.toPrecision(8) + "</p>";
document.getElementById("prompt").innerHTML=info;
}
</script>
</head>
<body onload="test();">
<h1>Mobile-Web-App: Javascript Exercise - number arithmetic, toFixed() and toPrecision()</h1>
<div id="prompt"></div>
</body>
</html>
Saturday, April 21, 2012
Javascript Exercise - number arithmetic, toFixed() and toPrecision()
Data type of Javascript: string and number
This exercise, the function typeof() is used to test the data type of various string and number object.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Mobile-Web-App: Javascript Exercise - data type</title>
<script>
function test(){
info = "<p>typeof \"\": " + typeof("") + "</p>"
+ "<p>typeof 'a': " + typeof('a') + "</p>"
+ "<p>typeof \"a\": " + typeof("a") + "</p>"
+ "<p>typeof 'abc': " + typeof('abc') + "</p>"
+ "<p>typeof \"abc\": " + typeof("abc") + "</p>"
+ "<p>typeof 0: " + typeof(0) + "</p>"
+ "<p>typeof 1: " + typeof(1) + "</p>"
+ "<p>typeof 1.0: " + typeof(1.0) + "</p>"
+ "<p>typeof 1.5: " + typeof(1.5) + "</p>"
+ "<p>typeof null: " + typeof(null) + "</p>";
document.getElementById("prompt").innerHTML=info;
}
</script>
</head>
<body onload="test();">
<h1>Mobile-Web-App: Javascript Exercise - data type</h1>
<div id="prompt"></div>
</body>
</html>
Friday, April 20, 2012
The D Programming Language
The D Programming Language combines modeling power, modern convenience, and native efficiency into one powerful language. D embodies many new ideas in programming languages along with traditional proven techniques.
Google JavaScript Style Guide
JavaScript is the main client-side scripting language used by many of Google's open-source projects. The on-line style guide, Google JavaScript Style Guide, is a list of dos and don'ts for JavaScript programs.
Link: http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml
Link: http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml
Check Browser Compatibility at quirksmode.org
QuirksMode.org is the prime source for browser compatibility information on the Internet. It is maintained by Peter-Paul Koch, mobile platform strategist in Amsterdam, the Netherlands.
QuirksMode.org is the home of the Browser Compatibility Tables, where you’ll find hype-free assessments of the major browsers’ CSS and JavaScript capabilities, as well as their adherence to the W3C standards.
It is also increasingly the home of ground-breaking mobile web research.
QuirksMode.org is the home of the Browser Compatibility Tables, where you’ll find hype-free assessments of the major browsers’ CSS and JavaScript capabilities, as well as their adherence to the W3C standards.
It is also increasingly the home of ground-breaking mobile web research.
Wednesday, April 18, 2012
ThemeRoller for jQuery Mobile
The ThemeRoller Mobile tool makes it easy to create custom-designed themes for your mobile site or app. Just pick colors, then share your theme URL, or download the theme and drop it into your site.
Try it: http://jquerymobile.com/themeroller/
Try it: http://jquerymobile.com/themeroller/
Detect browser info using navigator in Javascript
The following example show how to check browser info (appName, appCodeName, appVersion, platform and userAgent) using navigator in Javascript.
Screenshot of running in Opera on Linux desktop.
Screenshot of running in Chrome for Android, Beta.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Mobile-Web-App: Detect Browser</title>
<script type="text/javascript">
function detectbrowser(){
info = "<p><b>Browser info: </b></p>"
+ "<p>appName: " + navigator.appName + "</p>"
+ "<p>appCodeName: " + navigator.appCodeName + "</p>"
+ "<p>appVersion: " + navigator.appVersion + "</p>"
+ "<p>platform: " + navigator.platform + "</p>"
+ "<p>userAgent: " + navigator.userAgent + "</p>";
document.getElementById("browserinfo").innerHTML=info;
}
</script>
</head>
<body onload="detectbrowser();">
<h1>Mobile-Web-App: Javascript Exercise - Detect Browse</h1>
<div id="browserinfo"></div>
</body>
</html>
Screenshot of running in Opera on Linux desktop.
Screenshot of running in Chrome for Android, Beta.
Subscribe to:
Posts (Atom)





