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]]])
||The message that appears in the alert box.
||Optional. The title of the alert box. By default, this value is the file name of the script.
||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.
||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.
- Button Types
- OKOnly - Show the message box with an "OK" button.
- OKCancel - Show the message box with an "OK" and "Cancel" buttons.
- AbortRetryIgnore - Show the message box with an "Abort", "Retry" and "Ignore" buttons.
- YesNoCancel - Show the message box with an "Yes", "No" and "Cancel" buttons.
- YesNo - Show the message box with an "Yes" and "No" buttons.
- RetryCancel - Show the message box with an "Retry" and "Cancel" buttons.
- Icon Types
- Critical - Show the "Stop Mark" icon.
- Question - Show the "Question Mark" icon.
- Exclamation - Show the "Exclamation Mark" icon.
- Information - Show the "Information Mark" icon.
- Timeout - Returned if the message box timed out.
- OK - Returned when the "OK" button is pressed.
- Cancel - Returned when the "Cancel" button is pressed.
- Abort - Returned when the "Abort" button is pressed.
- Retry - Returned when the "Retry" button is pressed.
- Ignore - Returned when the "Ignore" button is pressed.
- Yes - Returned when the "Yes" button is pressed.
- No - Returned when the "No" button is pressed.
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:
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))
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",
alert("Good choice, there is no reason to have all of the junk on the web"
+ " anyway.", "Cancel Download", alert.Information);
alert("I guess you don't care what happens.", "Timeout Occurred");
Related Search Results
- 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]
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
- 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
- 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
- POW – Explain That SQL #1:
- Wormbites 2006:
The ultimate Snake game with multiple brain-teasing levels. You can also custom design you own levels.
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
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
© 2010 Christopher West. Powered by jPaq. This page is by Chris West.