[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-WebCGI] Pop-up requester



At 1:26 PM 8/7/00, Stephen Criddle wrote:
>I would like to get my script make the user's browser pop up a password
>requester, and then pick up what was typed.  I only want to prompt for a
>single field (ie. password), and I'd rather do it with a pop-up
>requester than have the password field on the submitted page.
>
>Is this something that is supported by HTML (since it's not a standard
>page)?
>
>OK, so technically it's not a MacPerl question, but presumably somebody
>has had to do this at some point.
>

To make this about MacPerl, what you're talking about could be done 
in a CGI context, with the script written in Perl, running in MacPerl 
if the web server is a Mac. When you say a 'pop-up requester' I 
assume you mean something like a dialog box. This is most easily done 
utilizing JavaScript, to control window size for example. However JS 
doesn't have a standard implementation across browser versions and 
brands, and many web users keep it turned off.

A current project of mine has a help system that pops up in a smaller 
window in front of the main web page. So this is a web page with some 
JS controls on it, rather than a pure JS dialog box, which might work 
for you. Here's the begining of the HTML returned by the CGI when 
Help links are clicked [somewhat simplified -- also our emailers 
might insert some linebreaks in this]:

## start code snippet ##
print "Content-type: text/html\n\n";

print <<HELP;
<HTML>
<HEAD>
<TITLE>Help</TITLE>
<BASE TARGET='Help'>
</HEAD>
<BODY 
onload="window.open('','Help','width=360,height=400,scrollbars,resizable,status'); 
window.focus()" bgcolor="#FFFFFF">

HELP
## end code snippet ##

1. Making the target 'Help' puts the web output in a window named 
'Help', creating a separate window if necessary. The phrase <BASE 
TARGET='Help'> makes any link _within_ the Help window also return 
its value within that window.

2. The onload=  statement is JS. "window.open(...)" opens the help 
window; you can read up on the arguments to window.open; what's 
relevant here is the second arg, naming the window; the width & 
height args, which make the Help window smaller than the main web 
page; and scrollbars, resizing, and status line enabled so the user 
can move or change the window (which you might not need for your 
purpose).

3. The second JS statement, "window.focus()", makes sure the Help 
window comes to the front after it opens or when it is called again.

This works just fine on my Mac with Netscape & Explorer (not yet with 
iCab), but I've heard from one Windows user who says the Help window 
won't resize, although I haven't looked at their setup, and it's 
possible they have JS disabled in their browser.

I avoid JS generally. The above benefits from JS if the user's 
browser is capable and enabled, but still works OK if not. There are 
probably JS experts who could hack out the browser workarounds well 
enough to something reliable for all users; but there are still those 
users who disable JS for speed, security, and annoyance-reduction.

As an alternative, just have the CGI return its request for a 
password as a standard web page in the main window with only password 
input field. The CGI then returns a new page whose content depends on 
password validity. If you want a separate window, you can use the 
"target=" attribute in the link to the password checker.

HTH.

1;


-- 

- Bruce

__Bruce_Van_Allen___bva@cruzio.com__Santa_Cruz_CA__

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org