469,271 Members | 1,416 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Can the "header" of a JavaScript dialogue box be changed?

When JavaScript writes out a dialogue box (like when confirm() is called)
the header or title of that dialogue box shows up as "JavaScript
Application"... Can this title be changed so that maybe you could stick the
name of your application in it?
Jul 23 '05 #1
8 11354
"Chris Markle" <cm*****@sendmail.com> skrev i meddelandet
news:GVwud.742045$8_6.299280@attbi_s04...
When JavaScript writes out a dialogue box (like when confirm() is called)
the header or title of that dialogue box shows up as "JavaScript
Application"... Can this title be changed so that maybe you could stick the name of your application in it?


No.

Joakim Braun
Jul 23 '05 #2
It'd be some fancy DHTML, but you could use an absolutely positioned
DIV tag to simulate a window and put a nested DIV inside it for the
title along with some text and buttons.

Jul 23 '05 #3
<html>
<head>
<title>test</title>
<script>

//Create a MessageBox class
function MessageBox(){
var Callback;

this.Show=
function(title, text, callback){

//Setup the event handler
this.Callback = callback;

//Set the text and show it
var h = window.document.getElementById("ConfirmTitle");
h.innerHTML = title;
h.parentNode.style.display="block";
window.document.getElementById("ConfirmText").inne rHTML = text;

Callback = callback;
}

this.Hide=
function(result){
var dv =
window.document.getElementById("ConfirmTitle").par entNode;
dv.style.display="none";
var s = Callback + "('" + result + "');";
eval(s);
}

this.AddToPage=
function(){

//Assemble a dialog and add it to the page
var i=0; var sb = new Array();
sb[i++]="<DIV style=\"font-family:sans-serif;display:none;
position:absolute;left:100px;";
sb[i++]="top:100px; width:200; border:solid 1px gainsboro;\">";
sb[i++]="<H5 id=\"ConfirmTitle\"
style=\"background-color:navy;color:white;\"></H5>";
sb[i++]="<P id=\"ConfirmText\"></P>";
sb[i++]="<input type=\"button\" value=\"yes\"
onclick=\"Msgbox.Hide('yes');\">";
sb[i++]="<input type=\"button\" value=\"no\"
onclick=\"Msgbox.Hide('no');\">";
sb[i++]="</DIV>";
document.write(sb.join(""));
}
this.AddToPage();
}

//Instantiate the Msgbox
var Msgbox = new MessageBox();
//Your function to do something with the result
function ResultHandler(result){
alert(result);
}

</script>
</head>
<body>
<A onclick="Msgbox.Show('Application Title','Text of the message
goes here... ','ResultHandler');" href="#" > Show Message </A>
</body>
</html>

Jul 23 '05 #4
Hi,

Chris Markle wrote:
When JavaScript writes out a dialogue box (like when confirm() is called)
the header or title of that dialogue box shows up as "JavaScript
Application"... Can this title be changed so that maybe you could stick the
name of your application in it?


You can't, but you can (and should) use a pop-up for this:

http://www.galasoft-lb.ch/myjavascri...000090401.html

The confirm, alert and input message boxes were never designed for user
interaction, only for debug purposes.

HTH,

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 23 '05 #5
Ivo
"Laurent Bugnion" wrote
Chris Markle wrote:
Javascript confirm call outputs a dialogue box that writes out a message
and gives two choices: OK and Cancel. Can those buttons be relabelled
say to "Yes" and "No"? You can't, but you can (and should) use a pop-up for this:


Yes, the other post was an exact copy. Was that necessary? So once again:
Another, perhaps even nicer solution is to use a pop-in, a <div> or <iframe>
or so with your own buttons which you show and hide at will, at the same
covering the page to temporarily disable interaction. This solves all
problems with pop-up blockers and no resources are wasted on a whole new
window.
The confirm, alert and input message boxes were never designed for
user interaction, only for debug purposes.


Their original purpose is as relevant as the next thing. Those message boxes
are extremely useful and useable and I am sure many end users, from geeks to
total newbies, appreciate their lightweightness, straightforwardness and
absolute clarity to the point where even the buttons *always* read the same
thing.
--
Ivo
http://www.yorick.onlyfools.com/


Jul 23 '05 #6
Hi,

Ivo wrote:
"Laurent Bugnion" wrote
Chris Markle wrote:
Javascript confirm call outputs a dialogue box that writes out a message
and gives two choices: OK and Cancel. Can those buttons be relabelled
say to "Yes" and "No"?
You can't, but you can (and should) use a pop-up for this:

Yes, the other post was an exact copy. Was that necessary?


If the OP feels the need to post two copies (almost) of a message, one
can reasonably expect that he will look for answers to both. Especially
in this case, where it's obvious that it's not an error. And anyway, why
does it matter to you?
So once again:
Another, perhaps even nicer solution is to use a pop-in, a <div> or <iframe>
or so with your own buttons which you show and hide at will, at the same
covering the page to temporarily disable interaction. This solves all
problems with pop-up blockers and no resources are wasted on a whole new
window.


I agree.
The confirm, alert and input message boxes were never designed for
user interaction, only for debug purposes.

Their original purpose is as relevant as the next thing. Those message boxes
are extremely useful and useable and I am sure many end users, from geeks to
total newbies, appreciate their lightweightness, straightforwardness and
absolute clarity to the point where even the buttons *always* read the same
thing.


Their original purpose is extremely relevant to explain why they look
like they do, and why the developer has almost no way to modify them or
make them look better.

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 23 '05 #7
Ivo
"Laurent Bugnion" wrote
Ivo wrote:
"Laurent Bugnion" wrote If the OP feels the need to post two copies (almost) of a message, one
can reasonably expect that he will look for answers to both. Especially
in this case, where it's obvious that it's not an error.


The OP could have put his questions in one post. Much more convenient for
everyone. You could have pointed that out to him.
And anyway, why does it matter to you?


I read it! I care. Whatever. I don't like my Usenet cluttered up with this
repeating copies of messages, and undoubtedly many others feel the same way,
now and until the end of the last Usenet archive.
The confirm, alert and input message boxes were never designed for
user interaction, only for debug purposes.


Their original purpose is as relevant as the next thing. Those message
boxesare extremely useful and useable and I am sure many end users, from
geeks to total newbies, appreciate their lightweightness,
straightforwardness andabsolute clarity to the point where even the
buttons *always* read the same thing.


Their original purpose is extremely relevant to explain why they look
like they do, and why the developer has almost no way to modify them or
make them look better.


Sure, it is relevant to explain those things. But when deciding on a way to
communicate with visitors to a webpage, the only things that count are
current things. Not original purposes. Just like the web's original purpose
was never anything pornographic or even commercial... From your words I get
the feeling that you find it wrong to use alerts and prompts in real-life
situations with real-life users, merely because of this original purpose. I
really don't follow, can't see any logic in that.
--
Ivo
http://4umi.com/web/javascript/





Jul 23 '05 #8
Hi,

Ivo wrote:
"Laurent Bugnion" wrote
Ivo wrote:
"Laurent Bugnion" wrote


If the OP feels the need to post two copies (almost) of a message, one
can reasonably expect that he will look for answers to both. Especially
in this case, where it's obvious that it's not an error.

The OP could have put his questions in one post. Much more convenient for
everyone. You could have pointed that out to him.


That's correct.
And anyway, why does it matter to you?

I read it! I care. Whatever. I don't like my Usenet cluttered up with this
repeating copies of messages, and undoubtedly many others feel the same way,
now and until the end of the last Usenet archive.


I was not aware it was your Usenet ;-) That said, you're right that
pointing it out to the OP would have been a good move.
Their original purpose is extremely relevant to explain why they look
like they do, and why the developer has almost no way to modify them or
make them look better.

Sure, it is relevant to explain those things. But when deciding on a way to
communicate with visitors to a webpage, the only things that count are
current things. Not original purposes. Just like the web's original purpose
was never anything pornographic or even commercial... From your words I get
the feeling that you find it wrong to use alerts and prompts in real-life
situations with real-life users, merely because of this original purpose. I
really don't follow, can't see any logic in that.


I do find it wrong when there are many better, more elegant ways, for
example, as you pointed out, floating DIVs and the such. That said, my
intent was not to force the OP to stop using alert confirm and input,
merely to explain why they look how they do. That could have been clearer.

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 23 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by beliavsky | last post: by
7 posts views Thread by Sherry Littletree | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.