Advertisement
planthed

popup box step 1

Sep 22nd, 2015
7,949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <script type="text/javascript"
  2. src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
  3. <script>
  4. $(document).ready(function() {
  5. //
  6. $('a.poplight[href^=#]').click(function() {
  7. var popID = $(this).attr('rel'); //Get Popup Name
  8. var popURL = $(this).attr('href'); //Get Popup href to define size
  9. var query= popURL.split('?');
  10. var dim= query[1].split('&');
  11. var popWidth = dim[0].split('=')[1]; //Gets the first query string value
  12. $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"></a>');
  13. var popMargTop = ($('#' + popID).height() + 80) / 2;
  14. var popMargLeft = ($('#' + popID).width() + 80) / 2;
  15. //Apply Margin to Popup
  16. $('#' + popID).css({
  17. 'margin-top' : -popMargTop,
  18. 'margin-left' : -popMargLeft
  19. });
  20. $('body').append('<div id="fade"></div>');
  21. $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'})
  22. return false;
  23. });
  24. $('a.close, #fade').live('click', function() {
  25. $('#fade , .popup_block').fadeOut(function() {
  26. $('#fade, a.close').remove(); //fade them both out
  27. });
  28. return false;
  29. });
  30. });
  31. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement