Jump to content

conditional call when "page leave"


vikaspa

Recommended Posts

I have page for checkout ( shopping cart)

When person leaves a page I have a javascript called

which gives alert

 

Are you sure you want to leave this page?

OK and Cancel button

 

 

Which works fine

 

However I donot want this alert when shopping cart is empty

or

 

I want this alert only when the page is left with entries in shopping cart

Link to comment
https://forums.phpfreaks.com/topic/227511-conditional-call-when-page-leave/
Share on other sites

You'll most likely have to use ajax to get the status of the shopping cart.

 

 

Or, you could use php to check if there are any items in the cart, and if there is, echo the javascript code for the alert, otherwise, don't echo it, so therefore it won't run. If that makes sense?

 

 

Denno

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.