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

C

Chris Markle

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?
 
J

Joakim Braun

Chris Markle said:
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
 
M

Marlais

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.
 
M

Marlais

<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").innerHTML = text;

Callback = callback;
}

this.Hide=
function(result){
var dv =
window.document.getElementById("ConfirmTitle").parentNode;
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>
 
L

Laurent Bugnion

Hi,

Chris said:
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/myjavascript/consulting/2000090401.html

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

HTH,

Laurent
 
I

Ivo

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.
 
L

Laurent Bugnion

Hi,
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.
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
 
I

Ivo

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.
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.
 
L

Laurent Bugnion

Hi,
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.
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.
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,433
Messages
2,571,683
Members
48,796
Latest member
Greg L.

Latest Threads

Top