Confirmation are most often used to confirm an important actions that are taking place on a website. For example, they may be used to confirm an order submission or notify visitors that a link they clicked will take them to another website.
Below is an example of how you would use a confirm dialogue box to warn users about something, giving them the option to either continue on or stay put.
If the user clicks OK, a value of 1 is returned. If a user clicks cancel, a value of 0 is returned.. We store this value in answer by setting it equal to the confirm function call.
After answer has stored the value, we then use answer as a conditional statement. If answer is anything but zero, then we will send the user away from Tizag.com. If answer is equal to zero, we will keep the user at Tizag.com because they clicked the Cancel button.
In this lesson, we also used the window.location property for the first time. Whatever we set window.location to will be where the browser is redirected to. In this example, we chose Google.com. We will discuss redirection in greater detail later on.
google_protectAndRun("render_ads.js::google_render_ad", google_handleError, google_render_ad);
|Herramientas||Modos de visualización|