Reputation: 6541
I want to run a - accept our terms pop up box - that must be accepted before the page can be seen. I think I found answers here: https://stackoverflow.com/questions/6588167/how-do-i-make-a-popup-appear-immediately-before-the-rest-of-the-page-loads
But I am at a loss to what I was doing wrong, and why my method had a time lag.
I uploaded http://jsfiddle.net/ZqVuj/2/ as example - If you click run you can see the lorem pops up for a moment then black. Why does the modal not work before the rest of the page loads?
Someone built the page Im on off the code from this page: http://www.queness.com/post/77/simple-jquery-modal-window-tutorial
I took out the fade-ins, and changed $(document).ready(function() to $(function()
Yet the text still loads for a moment before the modal kicks in. What am I doing wrong?
Upvotes: 0
Views: 91
Reputation: 324790
Instead of $(function() {...})
, use (function() { ... })();
and put it right at the top of the <body>
. That way, it will run instantly before the page content is shown.
Bear in mind, though, that anyone with basic knowledge of their browser can just remove the popup and reveal the content. You should use a more reliable method for securing your content.
Upvotes: 3