Felix Shnir wrote:
> umm, what?
>
> On 1/17/07, *Matt Fletcher* <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>     I am using a pop up window to display a URL. What I need to do is
>     return a value(s) from this pop up depending on what link a user
>     selected.
>
>      
>
>     This used to be done by code similar to the following:
>
>     vReturnValue = window.showModalDialog(url);
>
>     <execution pauses here>
>
>     window.returnValue = selectedVal;
>
>            
>
>     Is there an equivalent in the Prototype class as execution doesn't
>     pause even when the window is set to modal?
>
>      
>


Hi Matt,

These are very basic questions you are asking. Before trying to tackle 
anything with Prototype Windows, it is best to read a tutorial on 
JavaScript, and not VBScript, as that is what you seem to be using. 
showModalDialog was introduced in IE4 and has never been adopted by 
other browsers. It is considered a very bad habit to show a new window 
and preventing the user to access his main window. Unfortunately, the 
notorious window.alert() and window.prompt() still exist, but since a 
short while, Opera provides a way out of them and I hope other browsers 
will follow soon.

Because you don't want a user to do and act precisely when you want it 
and how you want (and even if you do, which I hope you don't, the user 
will feel differently about it), the Javascript model introduced 
asynchronous callbacks, also called: event mechanism. The basic is 
simple: when something happens (i.e., a user clicks a button, an 
XMLHttpRequest object finishes, or your own asynchronous function 
finishes) a method is called. Familiar are (I hope) methods like onload, 
onclick, onbeforeupdate (IE only) etc.

Like all good objects that support asynchronicity, Prototype.js and 
Prototype Windows (and just about any other serious JavaScript object 
library) support asynchronous callbacks when they need to. For instance, 
when a user resizes the window (when he starts, when he ends), when the 
user clicks the close button etc.

You'll have to get used to an event model of programming. "execution 
stops here" does not exist and is only used while debugging by using 
these notorious window.alerts (or a debugger, for that matter). So, to 
get what you want (a return value), use the Prototype Windows Classes, 
register your callback method with them (simply, just pass in the name 
of your method, see the documentation, it is all there) and place the 
code you would otherwise place after "execution stops here" in your 
callback method (or event handler, whatever name you choose for it). I 
believe the syntax in PWC was something like: onOk: myOkMethod.

The internet is filled with tutorials on the subject of JavaScript event 
model programming, both in depth and beginners. Have a shot at it and 
then try again to tackle PWC (or any JavaScript, for that matter). You 
will find that a whole new world opens up for you.

Good luck coding!

Cheers,
-- Abel Braaksma

_______________________________________________
Javawin mailing list
[email protected]
http://mail.xilinus.com/mailman/listinfo/javawin_xilinus.com

Reply via email to