|
I have been asked the question a few times
- so heres the deal.
I like using them! - some people might start
coughing now - but the reasons why are:
- No browser buttons that the user can misuse
(they created some data and now they press
the back button ring support and say the dumb
application isn't working again!)
- Always on top
- The user cannot click away until you decide
they can
With websites the above isn't needed - but
i dont create websites (I would be unemployed
- look at this one!) I create applications -
but everyone wants them to work in a browser.
Unfortunately a browser is as dumb as referees
in sports matches (for me its football) - and
just as blind to what is going on around them.
So for me the modal dialog capabilities of
IE help to protect the application (and the
user) from the browsers issues.
ok - a bit of code - to create a modal window
you use:
var data=window.showModalDialog(url
of your document,data to pass to document,"scroll:no;
dialogWidth:300px; dialogHeight:300px; center:yes")
To send data to the document you would do:
var dataarray as new Array()
dataarray[0]="fred"
dataarray[1]="bloggs"
This code would come before the above bit and
you would insert your dataarray in the second
parameter.
Once your window has launched with your notes
page,document - whatever - You would then be
able to retrieve and use the parameters using:
var incomingdata=window.dialogArguments
Therefore in this example incomingdata[0] would
equal fred incomingdata[1] would equal bloggs
and so on.
ok - now perhaps you would have some fields
on your document - maybe a bit of javascript
jigery pokery and now you want to close the
window and return the data.
So provide the user with a close button and
the following code will do the trick:
function soCloseMe(){
window.returnValue=outgoingdata
(an array constructed with the data you wish
to pass back - or could be a string)
window.close()
}
Now we come a full circle and we are back to
your original call:
var data=window.showModalDialog(url
of your document,data to pass to document,"scroll:no;
dialogWidth:300px; dialogHeight:300px; center:yes")
data now equals your outgoing data and you
can continue on your way.
Questions? -
steve.castledine@projectdx.org
|