how to make a window modal in nature

A

amith

Hi,

I have a javascript, calendar.js which i use to enable my client to
select the date. This calendar pops up on the click of a gif image.
But the problem is that this poped up window is not modal in nature(i
do not want the user to go the parent page unless he selects some date
in the calendar popup).

In the javascript calendar.js he has used window.open() function to
pop up the window. i just want to know whether we have any attribute
which when set to yes will make the window behave modal in
nature.(just like resizable="yes",toolbar="yes", do we have
modal="yes" ?)

i checked modal="yes" and it does not make the window behave modal in
nature. Am i using the wrong attribute name?(modal="yes").

Do we have such attribute. If not what are my other options.

I know that we can use window.showModalDialog(), but i need to modify
the window.open() function to make the window behave modally. Is it
possible to do so?

regards
Amith
 
R

Richard Cornford

This calendar pops up on the click of a gif image.
Sometimes.

But the problem is that this poped up window is not modal
in nature(i do not want the user to go the parent page
unless he selects some date in the calendar popup).

Even if the window was modal (including showModalDialog windows) it
would (and should) still be possible for the user to close it and return
to the parent without making a selection.
In the javascript calendar.js he has used window.open()
function to pop up the window. i just want to know whether
we have any attribute which when set to yes will make the
window behave modal in nature.(just like resizable="yes",
toolbar="yes", do we have modal="yes" ?)

No, the new browser instance that is one of the possible results of a
call to the window.open function is a separate process and is not modal
in nature and there are no window features list options that will make
it so. "dependent" (where implemented) comes closest with some browsers
but is so inconsistently implemented that it is probably best just to
leave that alone.
i checked modal="yes" and it does not make the window behave
modal in nature. Am i using the wrong attribute name?(modal="yes").

You can make up as may feature keys as you like, if they don't appear in
the documentation they are unlikely to do anything but harm.
Do we have such attribute.
No.

If not what are my other options.

1.Attempt to script the new window into a (pseudo) modal window by
monitoring the blur and focus events on all elements in each window so
that re-focusing the original window (or any of its contents) results in
the focus being passed back to the new window. This may sound like a
simple option but in reality is quite tricky to do well and has been
done badly in the past with sufficient frequency that recent browsers
are including user options to prevent scripts from actively focusing
window, so ultimately it can no longer be done reliably anyway. (not
that opening pop-up window can be done reliably anyway).

2.Re-design the process until the perceived need for the window to be
modal goes away (so it will not matter that it cannot reliably be made
so).

3.Navigate the current window to the calendar page, thus making
simultaneous interaction with the first page impossible.

4.Use an "in window pop-up" (DHTML) for the calendar instead of the new
window.
I know that we can use window.showModalDialog(),

It is an IE only feature so it would be inappropriate to use it on the
internet, at least without writing such a lot of fall-back code for
non-IE browsers that it would be easier to just use the
non-showModalDialog code for all browsers.
but i need to modify the window.open() function to
make the window behave modally. Is it possible to
do so?

If you put enough effort into the blur/focus script and think through,
and test, all of the possibilities then maybe. I would go with the "in
window pop-up" for that type of UI component if I wanted the modal
dialog effect, and navigating the current window if I wanted absolute
reliability.

Richard.
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top