spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / dhtml / column22
Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management
Logo

  JavaScript Enhancement with VBScript
  SPECIAL EDITION; the director's cut

Include the following scripts in the HEAD of your document (JS script must come first to set page script language default):

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--

IE4 = document.all;

function newAlert(title,mess,icon,mods) {
   (IE4) ? makeMsgBox(title,mess,icon,0,0,mods) : alert(mess);
}

function newConfirm(title,mess,icon,defbut,mods) {
   if (IE4) {
      icon = (icon==0) ? 0 : 2;
      defbut = (defbut==0) ? 0 : 1;
      retVal = makeMsgBox(title,mess,icon,4,defbut,mods);
      retVal = (retVal==6);
   }
   else {
      retVal = confirm(mess);
   }
   return retVal;
}

function newPrompt(title,mess,def) {
   retVal = (IE4) ? makeInputBox(title,mess,def) : prompt(mess,def);
   return retVal;
}

function IEBox(title,mess,icon,buts,defbut,mods) {
   retVal = (IE4) ? makeMsgBox(title,mess,icon,buts,defbut,mods) : null;
   return retVal;
}

//-->
</SCRIPT>

<SCRIPT LANGUAGE=VBScript TYPE="text/vbscript">
<!--

Function makeMsgBox(title,mess,icon,buts,defbut,mods)
   butVal = buts + (icon*16) + (defbut*256) + (mods*4096)
   makeMsgBox = MsgBox(mess,butVal,title)
End Function

Function makeInputBox(title,pr,def)
   makeInputBox = InputBox(pr,title,def)
End Function

-->
</SCRIPT>

Now, you can call the four JavaScript functions from anywhere in your page. Take care to pass the correct number of arguments:

newAlert(title,message,icon,modality)
        string, string, 0-4, 0/1

example: newAlert("DHTML Lab","No confusing captions",4,0)


newConfirm(title,message,icon,default button,modality)
          string, string, 0/1,       0/1,      0/1

example: newConfirm("DHTML Lab Confirmation Request","Are you confused yet?",1,1,0)


newPrompt(title,message,default response)
         string, string,    string

example: newPrompt("DHTML Lab User Input Request","Enter your name, please:","Ishmael")


IEBox(title,message,icon,button group,default button,modality)
     string, string, 0-4,       0-5,      0-2,        0/1

example: IEBox("DHTML Lab Explorer Dialog","All options enabled",1,2,2,1)



Produced by Peter Belesis and

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags

All Rights Reserved. Legal Notices.
Created: Nov. 18, 1998
Revised: Nov. 18, 1998

URL: http://www.webreference.com/dhtml/column22/allCode.html