confirm function।Create a Confirm Box in JavaScript
Step1
Write the code to call the confirm function, following the example below. The result from confirm is placed in the variable ok so it can be tested in subsequent logic.ok = confirm("Do you really want to do this?"); Step2
Concatenate strings using the "+" operator to display a message made up of several parts, as follows:ok = confirm ("Are you really " + age + " years old?"); - f you don't need to give the user the option to Cancel, consider using the
alertfunction instead. - Instead of storing the result from
confirmin a variable and testing it, you can test it directly within anifstatement with a construct such asif (confirm(...) { }. - Technically the
confirmfunction is a method on the JavaScript window object, and thus could be writtenwindow.confirm, but since JavaScript on web pages is executed within the context of the window object anyway, this is not necessary.
No comments:
Post a Comment