raymond_feliciano Posted August 21, 2012 Share Posted August 21, 2012 I have a site that logs a user in and does a db lookup to see if the user has acknowledged that they have read a file. If they have not they are sent to a page with links to the files which need to be read. Once they read the file and click the acknowledge link the php script adds this file name along with user name to a table named read. What I want to do is stop the user from navigating away from this page if they have not acknowledged that they read the files. How would I use the javascript onunload function and do an ajax request to check if they have read the files that need to be read. I am new to ajax so any help would be appreciated. Quote Link to comment Share on other sites More sharing options...
txmedic03 Posted November 20, 2012 Share Posted November 20, 2012 I'm thinking you can't stop them from leaving because they can just close the window and open a fresh window, but aside from that if I came to your site and you tried to force me to read something that I didn't want to it would be my last visit to your site. A message or something telling me I need to read it is one thing, but trying to force me to read it is unacceptable and the attempt to hijack my browser and force feed content like that is likely to lose you a lot of users. Just my personal opinion on the matter. Quote Link to comment Share on other sites More sharing options...
kicken Posted November 21, 2012 Share Posted November 21, 2012 All your check's to see if they read the file should be done server side. As you've described it, someone could just disable javascript to bypass all your checks and use the site anyway. What you need to do is in your server-side scripts after checking the login, check if they have read the required documents. If not, redirect them to the page to read them where they can then click a button at the bottom of the page to acknowledge having read it. Quote Link to comment 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.