[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...

Posts By Month