Asking for User Confirmation


<a href="anyPage.html"   onclick="return window.confirm('Do you really want to do this?');">Click here</a> 

JavaScript offers limited support for modal windows. The window.alert() method is fairly common, but there are other options as well. With window.confirm(), the user is presented with a Yes/No window. If Yes is clicked, window.confirm() returns TRue; otherwise, false. The preceding code (file confirm.html) uses this as the return value for a link, so if No is clicked, the link is not followed.

Warning

Note that this dialog is translated by browsers, so you should avoid text like "Click Yes to…" since users with a non-English system do not have a Yes button.





JavaScript Phrasebook(c) Essential Code and Commands
JavaScript Phrasebook
ISBN: 0672328801
EAN: 2147483647
Year: 2006
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net