09-09-2009

jQuery Quick and dirty modal box using jQuery

If you need a modal box quickly and have jQuery in place:

you can just adjust and paste the following line of code in any eventhandler to quickly flash a message in a modal box for a short period of time on the screen. Adjust the script to your needs:

var sMessage = 'hey you..... this is a message!';
$('body').append('<div style="display:none" id="orderInstructionContainer">'+sMessage+'</div>');
$('#orderInstructionContainer').css({position:'absolute',top:'40px',left:'50%',marginLeft:'-220px',fontWeight:'bold',lineHeight:'2em', background:'white',border:'3px double #ccc',padding:'100px'}).fadeIn('slow',function(){
	setTimeout(function(){$('#orderInstructionContainer').fadeOut()},6000);
});

Comments:

Your comment:

»
Ali Sarmadi 28/01/2010, 7:10 am
I am so glad to find this. Thanks a lot.

 

[x]