473,388 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

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 2808
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Andy Fish | last post by:
Hi, now I know what the alert() function does, but can anyone tell me where I can find the specification or standards for functions like alert() and confirm(). They don't seem to be part of...
9
by: Justin Koivisto | last post by:
Is there a way to create an alert-like message box that uses a custom image? Basically, I want to replace the default ! image with something else. -- Justin Koivisto - spam@koivi.com PHP...
9
by: Targa | last post by:
Ive seen alert scripts triggered by links but I need one that will cover any link or pressing the back/forward buttons. Any such thing? TIA
2
by: Mike | last post by:
My page populates a table with a list of names and other information from a JavaScript object. I receive changes (adds, change & delete) to that list, convert it into a JavaScript object. I do...
11
by: Alistair Saldanha | last post by:
I'm looking for the event that is fired by Internet Explorer to an "alert": <SCRIPT> Alert("You already have a session open") </SCRIPT> The event would be webBrowser.Document.???? Much...
3
by: dalei | last post by:
Is there a way to have non-English letters and symbols, such as the Greek letters or copyright sign, to appear in the box of alert()? Or is the alert () also available to people with other writing...
1
by: JAG | last post by:
I am getting an error using the replace method in one of my functions. I am using the replace method in the mail document function in my frameset .hta to change forward slashes to back slashes in...
3
by: John Passaniti | last post by:
Hopefully someone can point out what I'm doing wrong. I find myself having to dynamically create HTML code, and have found that the usual way you see to do this is an unreadable mess, like this:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.