We accept safe and secure Credit Card and PayPal Payments!
 
Perl Scripts

All Count
Attachment Mailer
Build A FAQ Plus
Clock In Center
eBackup Automated
Easy Poll
eSurvey
Fetch a File
Form Maker
Mailing List Server
MySQL Mate
PDF Creation
QCart
Quick Fix
Speed Search
Task Manager
Traffic Pack
Upload Plus
Upload Gold
Upload Pro
Website Manager

 
Free Perl Downloads

Main Page
404 Alerter
AccessLog Viewer
Build A FAQ
eBackup
ErrorLog Viewer
eVars - Server Info
HT Pass Creator
Upload Lite
Website Manager

 
JavaScripts

Alert Boxes
Browser Sniffer
Check email
Generators
Sudoku
Window Maker
More...

 
Extra Utilities

Ascii Codes
Color Picker
Font Finder
HT Pass Creator
Meta Cloak
Meta Magic
Pano Zooms
SlideShow
Server Size

 
Online Tutorials

Glossary
HTML
JavaScript
MySQL
SSI
Build Traffic
Other

 
Miscellaneous

About Us
Graphics
Testimonials
Installations
Latest versions

 
Flash poll

Does your Website use Flash?






View all Polls

Purchase Easy Poll for your site, only $29

Run Surveys on your site. Click here
 
Global Warming

Your energy bills doubled in exchange for clean energy such as wind and solar power?






View all Polls

Run Polls on your site. Click here

Run Surveys on your site. Click here
 
  Store   Download   FAQs   Contact Us   Support   Custom Programming   Policies
Files uploaded and delivered to your inbox from your contact forms Attachment FormMail Manager with Anti-Virus Protection

JavaScripts :: Miscellaneous :: Alerts, Confirms and Prompts

Using Microsoft's propriety VBScript, you have a little more control of prompts and alerts. Below are some examples showing you how to add your own title to the popups. Note that VBScript is only supported by Internet Explorer. Netscape will show a regular alert, confirm or prompt. IE5 means IE5+ so IE6 will also be taken into account.

Note also that when using JavaScript and VBScript on the same page you must define a value in the language attribute. Eg.

<script language="VBScript">

or

<script language="JavaScript">

This rule is waived if the VBScript is last script tag on your page.


The Script

<script>
<!--
// Browser sniffer. Written by PerlScriptsJavaScripts.com

v3 = 0; op = 0; ie4  = 0; ie5 = 0; nn4 = 0; nn6 = 0; isMac = 0;

if(document.images){
    if(navigator.userAgent.indexOf("Opera") != -1){
        op = 1;
    } else {
        ie4 = (document.all && !document.getElementById);
        nn4 = (document.layers);
        ie5 = (document.all && document.getElementById);
        nn6 = (document.addEventListener);
    }
} else {
    v3 = 1;    
}

if(navigator.userAgent.indexOf("Mac") != -1){
    isMac = 1;
}

// start the actual code for an alert

function alert_confirm(){
    if(ie4 || ie5){
        // if its IE4+ call the VB Script 
        retVal = makeMsgBox("Hi","how are you?",32,1,256,4096);
		
        // which button was pressed?
        if(retVal == 1)            {alert("Ok pressed");}
        else if (retVal == 2)      {alert("Canceled");}
    } else {
        // else use a simple alert
        alert("I am not IE");
    }
}

// start the code for a prompt

function input_box(){
    
    // only three args here
    // Title, Question, Default answer
    
    if(ie4 || ie5){
        retVal = makeInputBox("Hi","How are you?","Fine, thanks");
    } else {
        retVal = prompt("How are you?","Fine, thanks");
    }
    
    if(retVal){
        alert("Submitted");
    } else {
        alert("canceled");
    }
}
// -->
</script>

This is the VB SCript called by the code above if IE is detected.

<script language="VBScript">
<!--
Function makeMsgBox(tit,mess,icon,buts,defs,mode)
   butVal = icon + buts + defs + mode
   makeMsgBox = MsgBox(mess,butVal,tit)
End Function

Function makeInputBox(title,question,default_answer)
   makeInputBox = InputBox(title,question,default_answer)
End Function
// -->
</script>
Internet Explorer will call the VB Script while Netscape will execute the JavaScript. Below is a list of arguments each function takes. For example, if you look at the script above, you will find this line of code :

retVal = makeMsgBox("Hi","how are you?",32,1,256,4096);

You can change the numbers to create alerts, confirms or any type of popup using the numbers / arguments below.

The alert and confirm boxes take 4 arguments

Argument one : The Icon         0  = none
                                16 = X 
                                32 = ? 
                                48 = ! 
                                64 = i 

Argument two : The buttons      0 = OK   # standard alert
                                1 = OK CANCEL
                                2 = ABORT RETRY IGNORE
                                3 = YES NO CANCEL
                                4 = YES NO
                                5 = RETRY CANCEL 

Argument three :                0    = First
In your popup, which            256  = Second
button should be selected       512  = Thrid
by default?

Argument four :                 0    = Browser stalls
The system command will         4096 = All apps stall
stall either the browser 
or the whole system until 
the user responds 
(either submits or cancels)


A value is returned 
depending on which button 
was pressed. So you could say 

if(retVal == 3){do this} 
else {do this}

Here are the return values      OK      = 1 
                                Cancel 	= 2 
                                Abort 	= 3 
                                Retry 	= 4 
                                Ignore 	= 5 
                                Yes     = 6 
                                No      = 7 

Alert or Confirm box

Input box
Speed Search our site

Search script for your site
Linux Hosting Plans from $9.12 per month, includes Plesk Control Panel, MySQL databases, cgi-bin, crontab manager and 50 email accounts.
Xizzo : PC Password Manager
Linux Hosting Plans from $9.12 per month, includes Plesk Control Panel, MySQL databases, cgi-bin, crontab manager and 50 email accounts.

Discounted Scripts
Subscribe to our periodial newsletter to receive special offers.

Global Warming
Your energy bills doubled in exchange for clean energy such as wind and solar power?






View all Polls

Run Polls on your site. Click here
About us | Contact us | Script FAQs | Script Support | Website Hosting | Our Policies | Store | Testimonials
Subscribe to our periodical newsletter and receive notifications of Perl Script updates, new CGI Script releases and Special discounted offers. Existing Subscribers log in here.    
HTML Plain text
©1999 - 2007 All content Copyright PerlScriptsJavaScripts.com Proudly hosted by LinuxHostingPlans.com