Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 333
  • Last Modified:

title of a box (e.g. alert box)

hi,

how can i set the title of a popup box e.g. an alert box.
now, the text "microsoft internet explorer" is displayed.

additionally id'd like to know if i can change the icon being displayed. now a "!" is displayed.


thanks
hreinart
0
hreinart
Asked:
hreinart
  • 6
  • 4
  • 2
  • +1
1 Solution
 
Göran AnderssonCommented:
You can't.

You can use window.ShowModalDialog to open up a small web page in a dialog window. This will work just like an alert, but you can do most things that you can do in a normal window. A bit tricker to work with, though...
0
 
ramsesCommented:
YES YOU CAN!

All you need to do is write a litle VBSCRIPT routine and then call it from javascript!

And example of this can be found at the following url:

http://www.webreference.com/dhtml/column22/js-vbMsgBox.html

This will show you how to give the users a standard windows msgbox with all icons that you are used to, like the exclamation icon, the queston icon, the information icon and the critical icon, allows you to set the Msgbox Title, and choose what buttons the user can press: Yes, No, Retry, Cancel, Abort, Ignore, as well as set other flags like which button is default and application or system modal msgboxes.

On the same tutorial, you will also learn how to pop up just the InputBox you'll want to use, and plenty of other stuff.

Don't be allarmed because it's VBSCRIPT...  Almost every browser is capable of processing it, and if it doesn't, the script is cross-browser compatible, meaning that if the browser does not support vbscript, it will use the javascript equivalents.  Plain and simple!

Just use the functions provided in the tutorial and your visiters will see a web-page behaving like a real windows-application!


Ramses says Roooar
0
 
hreinartAuthor Commented:
hi ramses,

this looks very nice.
if i put the messagebox into my page, i only see the text.

could you give me the source for 1 simple page just displaying this box?


thanks
hreinart
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ramsesCommented:
I will... hold on


BTW: if you use Netscape it's possible you get the Javascript alertbox

(depends on wich version)


Hold on a few minutes while i look for the source
0
 
ramsesCommented:
Here you go!

Just copy and paste it into a html file, open it in your browser and press the Click Me button.

In MSIE you'll see the enhanced msgboxes and in NS you see the standard msgboxes

<HTML>
<HEAD>
<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 IEBox(title,mess,icon,buts,defbut,mods) {
   retVal = (IE4) ? makeMsgBox(title,mess,icon,buts,defbut,mods) : null;
   return retVal;
}
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;
}

//-->
</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>
</HEAD>
<BODY>
<BUTTON ONCLICK="newConfirm('Question','Wanna continue?',2,1,0)">Click me</BUTTON>
</BODY>
</HTML>
0
 
hreinartAuthor Commented:
i'm using ie5

..will look on your code now...
0
 
ramsesCommented:
ok
0
 
hreinartAuthor Commented:
hi,

i see the messagebox.
the title is:

vbscript:question


how can i change this?
..e,g,. "this is my messagebox"
0
 
ramsesCommented:
You can change the "Question", but not the Vbscript:

To change the "Question" caption, just alter the code that gets fired when you click the Click me button

<BUTTON ONCLICK="newConfirm('This is my Msgbox','Wanna continue?',2,1,0)">Click me</BUTTON>

with the functions listed above in your <head> section


If you want to be able to use msgboxes without the VBScript prefix, you'll have to use a custom OCX

I can make this very fast if you will, but then your users will have to accept a security warning.  The advantage is then that it will work cross-browser, i mean both NS and MSIE users will have the msgboxes


Ramses says Rooar!
0
 
ramsesCommented:
Hi there

I've made the ocx for you!

Just look at http://www.vep.be/msgbox/ and you'll see!


Ramses says Roooar!
0
 
MoondancerCommented:
This question remains LOCKED but open, awaiting your decision to update and finalize.
Moondancer
Community Support Moderator @ Experts Exchange
0
 
hreinartAuthor Commented:
works fine, sorry for beeing late here !
0
 
MoondancerCommented:
Your responsiveness here is very much appreciated.
Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now