[X]

Javascript Alert, Prompt, Confirm and Write function - (Learning Javascript Series)

Javascript functions: alert, prompt, confirm and write

Alert, prompt and document.write functions are most commonly used for user interaction and writing some content on browser window.

  • Alert is used to display some warning message window
  • Prompt is used to capture user input
  • Confirm is used to capture Yes/No or OK/Cancel response from user in order to perform further activity
  • Write is used to write some text on browser window.

Below are some examples of using these functions.

 

Using Alert function:

 

var browserInfo = '';
        browserInfo = "Browser CodeName: " + navigator.appCodeName + "\n\r";
        browserInfo += "Browser Name: " + navigator.appName + "\n\r";
        browserInfo += "Browser Version: " + navigator.appVersion + "\n\r";
        browserInfo += "Cookies Enabled: " + navigator.cookieEnabled + "\n\r";
        browserInfo += "Platform: " + navigator.platform + "\n\r";
        browserInfo += "User Agent: " + navigator.userAgent + "\n\r";
        alert(browserInfo);

 

 

 

More...

What is JavaScript - (Learning JavaScript Series)

The Javascript Language (File Extension .js)

Javascript is often confused with Java, but It has nothing to do with "Java Programming Language". It is a client side scripting language which supports object oriented, imperative and functional programming style. Javascript is mainly used in web pages and now a days it is implemented as part of web browsers (by default javascript is enabled in most of the browsers, but you can disable if you want). But it is not only restricted to web page and used in pdf documents and desktop widgets as well.

What is scripting language? "Scripting language is not compiled rather it is interpreted. VBScript and Perl are other scripting languages."

Javascript is most frequently used as cilent side validation on web pages. But it is also used in areas like

  • Google Adsense scripts are javascript, which are placed to show ads
  • Google Analytics, web site visitor tracking, is also javascript
  • Javascript is used in serving asynchronous content on web pages

History of Javascript

Javascript was originally developed for Netscape browser by Brendan Eich and was named as "Mocha" and made its first appearance in Netscape 2.0 in 1995, later it renamed to "LiveScript" and finally "JavaScript" as it is been claimed that the name is result of a co-marketing deal between "Netscape" and "Java". JavaScript was originally designed to help integrate HTML pages with "Java applets" - Java applications embedded in web pages. As of year 2011 javascript's current version is 1.8.5.

"JavaScript" is a trademark of "Oracle Corporation" and used under license for technology invented and implemented by "Netscape Communications" and current entities such as the "Mozilla Foundation".

"JavaScript" is officially managed by "Mozilla Foundation" and new language features are added from time to time. However some "Vendor Specific JavaScript" extensions also exist.

"JavaScript" supports much of the structured programming syntax from "C" langugage.

More...

Posts By Month