Link to home
Start Free TrialLog in
Avatar of hreinart
hreinart

asked on

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
Avatar of Göran Andersson
Göran Andersson
Flag of Sweden image

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...
ASKER CERTIFIED SOLUTION
Avatar of ramses
ramses

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hreinart
hreinart

ASKER

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
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
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>
i'm using ie5

..will look on your code now...
ok
hi,

i see the messagebox.
the title is:

vbscript:question


how can i change this?
..e,g,. "this is my messagebox"
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!
Hi there

I've made the ocx for you!

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


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