raymond_feliciano Posted August 21, 2012 Share Posted August 21, 2012 I just recently taken over a website. The owner has a system that alerts the user if the have any unread files that need to be read. Here are the steps, 1.The user logs in 2.The scripts does a db lookup to check if they have any unread files if they don't, they are sent to the main index page 3.If they have any unread files then they will be sent to another page with links to the fiels which need to be read and acknowledged. 4.Once they acknowledged they read the file the script adds this file name to the db which tells the system they have read it so they no longer receive the alert. The problem is if the user chooses not to read they can navigate away from the page. What I would like to is stop them from navigating to any other part of the website untill they acknowledged that they have read the file. Can I accomplish this with php and javascript/Ajax and how? Any help would be helpful. Quote Link to comment https://forums.phpfreaks.com/topic/267384-stop-user-from-navigation-away-from-page-if-a-certain-task-is-not-completed/ Share on other sites More sharing options...
scootstah Posted August 21, 2012 Share Posted August 21, 2012 The only way is to use Javascript's onunload event. It's easily bypassed, so it can't be relied on. Quote Link to comment https://forums.phpfreaks.com/topic/267384-stop-user-from-navigation-away-from-page-if-a-certain-task-is-not-completed/#findComment-1371168 Share on other sites More sharing options...
requinix Posted August 21, 2012 Share Posted August 21, 2012 Treat it like a login action: they cannot use the rest of the site until they "log in" (by viewing that file). If they try to get around it then they're re-presented with the "log in" prompt until they give up. Quote Link to comment https://forums.phpfreaks.com/topic/267384-stop-user-from-navigation-away-from-page-if-a-certain-task-is-not-completed/#findComment-1371180 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.