Hi,
I am using the to implement a popup window using zIndex... things work well but I want to implement a function, that is when user click any region that is outside of the popup div, the div will be closed, how to do that?
Bin
Hi,
I am using the to implement a popup window using zIndex... things work well but I want to implement a function, that is when user click any region that is outside of the popup div, the div will be closed, how to do that?
Bin
(function($){
   $.fn.outside = function(ename, cb){
      return this.each(function(){
         var $this = $(this),
              self = this;
         $(document).bind(ename, function tempo(e){
             if(e.target !== self && !$.contains(self, e.target)){
                cb.apply(self, [e]);
                if(!self.parentNode) $(document).unbind(ename, tempo);
             }
         });
      });
   };
}(jQuery));
That is a copy&paste code from
An easy way to do this is to cover your page with a transparent (could also be completely transparent) mask using a div.
Attach a click handler on this mask div to close out the popup.
See example here: http://www.sohtanaka.com/web-design/examples/modal-window/