Posted By

iamntz on 09/25/08


Tagged

javascript jquery modalbox


Versions (?)

Ntz Modal Box


 / Published in: JavaScript
 

URL: dev.iamntz.com

  1. var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
  2. function modalBox(content, width, callback) {
  3. if(!content){
  4. $('#ntz_modal').remove();
  5. $('#ntz_overlay').fadeOut(function(){$(this).remove();});
  6. try{if(IE6){$('body').find('select').visibility('visible');}}catch(err){};
  7. return false;
  8. }
  9. try{if(IE6){$('body').find('select').visibility('hidden');}}catch(err){};
  10. $('body').append('<div id="ntz_overlay"></div>');
  11. $('#ntz_overlay').css({
  12. width : '100%',
  13. height : $(document).height(),
  14. position : 'absolute',
  15. left : 0,
  16. top : 0,
  17. backgroundColor : '#FFFFFF',
  18. zIndex : 9990,
  19. opacity : 0
  20. }).fadeTo(200, 0.5);
  21. $('body').append('<div id="ntz_modal"></div>');
  22. $('#ntz_modal').css({
  23. border : '1px solid #2d7abb',
  24. width : width ? width : 350,
  25. backgroundColor : '#FFFFFF',
  26. position : 'absolute',
  27. left : '50%',
  28. top : $(document).scrollTop(),
  29. zIndex : 9995,
  30. marginLeft: -(Math.ceil((width ? width : 800)/2))
  31. }).append(content);
  32. try{
  33. callback.call();
  34. }catch(err){};
  35. $(document).bind('scroll', function(){
  36. $('#ntz_modal').css({
  37. top:$(document).scrollTop()
  38. });
  39. });
  40. };

Report this snippet  

You need to login to post a comment.