469,280 Members | 2,385 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Replace alert/prompt/confirm in unicode environment!

Hi!

I have an asp application where I use a lot of javascript for validations
etc and as it is today I use alert, confirm and prompt dialogs. Now we are
adding support for unicode and I have problems with the font used to present
messages in alert, prompts and confirm dialogs. If I for examle paste a
chinese value in a prompt dialog it is shown om my machine as a vertical
bar. When I write the value back to a textbox <input type="text" the correct
chinese character is shown. The problem seems to be the font used in the
dialogs. I tried to change the font but could not get this to work.

So I'm looking to create my own dialogs replacing the alert/prompt/confirm.
Alerts can be replaced by either a popup window presenting the text in pure
html (a bit slow because of roundtrip to server) or a message could be
presented using dhtml (div or span). I have harder to fix the confirm/prompt
where I'm expecting a return value.

I have to support IE5.5sp2 and higher and also Netscape 7+ so I cannot use
the IE specific showModalDialog.

Any example how to solve this would be great!

Regards
/Hans
Jul 23 '05 #1
2 2621
"Hans" <so***@nospam.com> wrote in message
news:cs**********@green.tninet.se...
Hi!

So I'm looking to create my own dialogs replacing the
alert/prompt/confirm.
Alerts can be replaced by either a popup window presenting the text in
pure
html (a bit slow because of roundtrip to server) or a message could be
presented using dhtml (div or span). I have harder to fix the
confirm/prompt
where I'm expecting a return value.
You can open a new window and display "custom" content without making a
trip to the server. Let me say this is a completely contrived example,
your definition of morning, afternoon, evening and night may be
completely different, the time and/or time zone on the visitor's system
may be incorrect, etc. It is just an example of how to display dynamic
content without resorting to a trip to the server:

<script type="text/javascript">
var now = new Date();
var hours = now.getHours();
var greeting = 'Good ';
if (hours < 12)
{
greeting += 'morning';
}
else if (hours < 18)
{
greeting += 'afternoon';
}
else if (hours < 20)
{
greeting += 'evening';
}
else
{
greeting += 'night';
}
window.newWindowHtml = [
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',
'<html>',
'<head>',
'<title>Untitled</title>',
'</head>',
'<body>',
greeting,
'</body>',
'</html>'
].join('\n');
var w = window.open(
'javascript:opener.newWindowHtml',
'windowName',
'...attributes...'
);
</script>
Any example how to solve this would be great!


As long as this is an Intranet (or otherwise controlled environment)
where you can _guarantee_ your users will always have JavaScript enabled
and will always allow popups, you can use windows created with
window.open() to create custom prompts and obtain feedback.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #2
Hi Grant and thanks for the answer!

This is an intranet environment and I know for sure javascript is enabled.

The code I have today (as I said) uses for example prompt, confirm and I
want to make as few changes in the code as possible to remove the use of
those functions. For example I use confirm when a user tries to delete a
record.

if (confirm("Delete record"))

//do the actual delete

else

//do nothing or whatever is supposed to happen when the user is pressing
cancel.

One of the problems I have removing the confirm here is that a confirm is
waiting for an answer. If I open a new window how can I do this and stop
executing the actual delete until the user presses yes in the opened window?
The only solution I found was to split this into two functions. One that is
called when the user wants to delete a record. This function will open a new
window asking if he/she really wants to delete the record and if they press
yes I call another function in the opener window that do the actual delete.

Another solution I was looking at was to show a <div> with OK/cancel buttons
in it but the problem I have here is that I want the div to show up where
the user clicks on the delete button and I have problems with IE and
<select> tags where <div> are put behind the dropdown list. Since the
arrangement of fields is very flexible in the system dropdowns, edit boxes
etc may be placed almost anywhere so I cannot find a place to show the <div>
and be 100% sure it will not be behind a dropdown list.

Regards

/Hans
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Andy Fish | last post: by
9 posts views Thread by Justin Koivisto | last post: by
9 posts views Thread by Targa | last post: by
2 posts views Thread by Mike | last post: by
11 posts views Thread by Alistair Saldanha | last post: by
3 posts views Thread by dalei | last post: by
1 post views Thread by JAG | last post: by
3 posts views Thread by John Passaniti | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.