JScript - Modified Alert Box
Main Menu Home HTA JavaScript PHP Examples Million Digit Number Free Samples Disable Excel Menus Display Random Facts Drive Information Emulate Lock Keys Enable Excel Menus Hoax Virus Message Includables jPaq Modified Alert Box toVBArray() Outer Links MSDN Reference JScript Reference

Now Available In jPaq!!!

Now this function is available in the custom JScript library, jPaq.  The nice thing about jPaq is that everything is documented and the library that you download is specifically tailored to your needs. Click here to create your own free jPaq today!


Give the scripter the ability to use the alert(...) function in any stand-alone JScript file.


You can find this helpful 424 byte script here.


alert(message [, title [, options [, duration]]])

description The message that appears in the alert box.
title Optional. The title of the alert box. By default, this value is the file name of the script.
options Optional. The button type and icon type you would like to appear in the alert box. By default, this value is set to alert.Exclamation + alert.OKOnly.
duration Optional. The duration in seconds that the alert box will appear before ending and returning alert.Timeout. If none is specified, the alert box will never timeout.


If a timeout occurs, alert.Timeout is returned. If a timeout doesn't occur, the response constant associated with the button pressed will be returned.


Example Code:

NOTE: All of these examples presuppose that the code from ModifiedAlertBox.js is encountered first.

The following code will display a typical alert box, almost identical to the one displayed when clicking here:

alert("Hello world!!!");

The following code will display an alert box with a message of "Where in the world is Carmen Sandiego?" and a title of "Carmen Sandiego":

alert("Where in the world is Carmen Sandiego?", "Carmen Sandiego");

The following code will display an alert box with a message of "I am the computer which means I am always right.", a title of "Computer Rules", and the Information icon:

alert("I am the computer which means I am always right.", "Computer Rules", alert.Information);

The following code will display an alert box with a message of "Is your PC slow?", a title of "PC Speed", the Question icon, and the "Yes" and "No" buttons. After the user picks one of the buttons, he or she will be informed of which button was chosen:

if(alert("Is your PC slow?", "PC Speed", alert.YesNo + alert.Information) == alert.Yes)
	alert("I see that you believe your PC is slow.  I really wish I could help.",
		"Slow PC", alert.Information);
	alert("I am glad to hear that you don't think your PC is slow.",
		"PC Isn't Slow", alert.Information);

The following code will display an alert box with a message of "Your PC couldn't download the Internet.", a title of "Download Unsucessful", the Exclamation icon, and the "Retry" and "Cancel" buttons. If the user waits more than five seconds, the alert box will time out and a new message will be displayed. If the user doesn't let the alert box timeout, an appropriate message will displayed, making it obvious which button was clicked:

switch(alert("Your PC couldn't download the Internet.", "Download Unsucessful",
	alert.RetryCancel + alert.Exclamation, 5))
	case alert.Retry:
		alert("Sorry, but I think that it would be a waste of both your time and my"
			+ " time if I try to download the Internet.", "Can't Retry Download",
	case alert.Cancel:
		alert("Good choice, there is no reason to have all of the junk on the web"
			+ " anyway.", "Cancel Download", alert.Information);
	case alert.Timeout:
		alert("I guess you don't care what happens.", "Timeout Occurred");

Related Search Results

  1. String.prototype.expandTabs():
    I personally love both JavaScript and Python. For this reason, from time to time I like to port functions that are available in Python, over to JavaScript. The following is a port of the expandTabs function. String.prototype.expandTabs = function(tabSize)
  2. Java Life Rap Song:
    This is a pretty funny and yet kinda good rap song about Java (the programming language of course :)): [hide-this-part morelink="Show the Video"] [/hide-this-part]
  3. Apache – Using Minified JavaScript If Available:
    I am currently working on a totally new layout and was recently trying to ensure that if the minified version of a JS file existed on my site, it would be used instead of the normal version. Thusly, I decided to use Apache’s .htaccess file to create
  4. JavaScript Snippet – String.prototype.contains():
    The following is a quick JavaScript function which can determine if a string contains a substring: String.prototype.contains = function(str, ignoreCase) { return (ignoreCase ? this.toUpperCase() : this) .indexOf(ignoreCase ? str.toUpperCase() : str) >
  5. JScript – Recursively Call A Script:
    Have you ever wondered how you can recursively call a JScript? Here is an example which shows how it can be done: WshShell = new ActiveXObject("WScript.Shell"); switch(WshShell.Popup("Do you want to run this script again?", 10, "Run Sc
  6. OpenKM Scripting – Creating Folders:
    We recently had the need to create hundreds of folders but didn’t want to do so manually. Unfortunately, this wasn’t as easy as simply going into the database and adding them. Fortunately, it was as easy as using the following script: import c
  7. POW – Explain That SQL #1:
    Someone asked me to quickly write them some code in any language that would accomplish a certain task. The following, which is in PostgreSQL, is the second solution that I came up with after doing the first one in my favorite language, JavaScript: SELECT
  8. Wormbites 2006:
    The ultimate Snake game with multiple brain-teasing levels. You can also custom design you own levels.
  9. JavaScript – Removing Text Nodes:
    Recently I have been involved in modifying websites with a module that allows for CSS and JS insertion. A bothersome issue that has arisen a few times is the fact that this tool doesn’t currently provide a way to remove the text nodes of just the ta
  10. JavaScript – Logical Operator Array Functions:
    As a follow-up to my previous article about the AND (&&) and OR (||) logical operators, I decided to create to Array prototype functions that mimic these operators to a certain degree: // If array is empty, undefined is returned. If no