Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HTML:
- <!--MODALS BEGIN HERE------------------>
- <div id="new-post-modal" class="modalDialog">
- <div> <a href="#close" title="Close" class="close">×</a>
- <div class="modal-header">
- <div class="modal-content" id=modal-header>
- <h2>New Post</h2>
- </div>
- </div>
- <div class="modal-body">
- <div class="modal-content">
- <p>This is a sample modal box that can be created using the powers of CSS3.</p>
- <p>You could do a lot of things here like have a pop-up ad that shows when your website loads, or create a login/register form for users.</p>
- </div>
- </div>
- <div class="modal-footer">
- <div class="modal-content">
- <a>Make sure to include enough details in your post!</a>
- </div>
- </div>
- </div>
- </div>
- <!----------SEPERATOR-------------->
- <div id="sign-in-modal" class="modalDialog">
- <div> <a href="#close" title="Close" class="close">×</a>
- <div class="modal-header">
- <div class="modal-content" id=modal-header>
- <h2>Sign In</h2>
- </div>
- </div>
- <div class="modal-body">
- <div class="modal-content">
- <p>This is a sample modal box that can be created using the powers of CSS3.</p>
- <p>You could do a lot of things here like have a pop-up ad that shows when your website loads, or create a login/register form for users.</p>
- </div>
- </div>
- <div class="modal-footer">
- <div class="modal-content">
- <a href="http://www.frostburg.edu/computing/get-connected/password-management/">Forgot your password or having login issues?</a>
- </div>
- </div>
- </div>
- </div>
- JS:
- //CODE TO CLOSE MODAL IF USER CLICKS OUTSIDE OR PRESSES ESC
- function modalClose() {
- if (location.hash == '#new-post-modal' || location.hash == '#sign-in-modal') {
- location.hash = '';
- }
- }
- document.addEventListener('keyup', function(e) {
- if (e.keyCode == 27) {
- modalClose();
- }
- });
- var modal = document.querySelector('#new-post-modal', '#sign-in-modal');
- modal.addEventListener('click', function(e) {
- modalClose();
- }, false);
- modal.children[0].addEventListener('click', function(e) {
- e.stopPropagation();
- }, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement