Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Web
Expertise: Intermediate
Jun 3, 1999



Application Security Testing: An Integral Part of DevOps

Implement a Confirm Box That Redirects Based on a User's Choice

You can easily create a function that redirects to a different page depending on a user's choice of OK or Cancel. You should use JavaScript's confirm command and then based on what is returned change the location property of the window object appropriately. For example:
function confirmRedirect(prompt, okURL, cancelURL)
	var confirmResult;

	// ask the user to chose either OK or Cancel
	confirmResult = confirm(prompt);

	// switch to a new URL based on the user's choice
	if (confirmResult) {
		window.location = okURL;
	} else {
		window.location = cancelURL;
// -->
Click here to go to a new page:<BR>
<INPUT TYPE="button" VALUE="New Page"
onClick="confirmRedirect('Where do you want to go
Boris Feldman
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date