Вот он. (function ($) { function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); } else var expires = ""; document.cookie = name + "=" + value + expires + "; path=/"; }; function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; }; function hideFlash() { var embeds = document.getElementsByTagName('embed'); for (i = 0; i < embeds.length; i++) { embeds[i].style.visibility = 'hidden'; } var objects = document.getElementsByTagName('object'); for (i = 0; i < objects.length; i++) { objects[i].style.visibility = 'hidden'; } var iframes = document.getElementsByTagName('iframe'); for (i = 0; i < iframes.length; i++) { iframes[i].style.visibility = 'hidden'; } }; function showFlash() { var embeds = document.getElementsByTagName('embed'); for (i = 0; i < embeds.length; i++) { embeds[i].style.visibility = 'visible'; } var objects = document.getElementsByTagName('object'); for (i = 0; i < objects.length; i++) { objects[i].style.visibility = 'visible'; } var iframes = document.getElementsByTagName('iframe'); for (i = 0; i < iframes.length; i++) { iframes[i].style.visibility = 'visible'; } }; /** * When the open event is called, this function will be used to 'open' * the overlay, container and data portions of the modal dialog. * * onOpen callbacks need to handle 'opening' the overlay, container * and data. */ function modalOpen(dialog) { $.fn.exitpopup.modelDlgShown++; hideFlash(); dialog.overlay.fadeIn('fast', function () { dialog.container.fadeIn('fast', function () { dialog.data.hide().slideDown('fast'); }); }); }; /** * When the close event is called, this function will be used to 'close' * the overlay, container and data portions of the modal dialog. * * The SimpleModal close function will still perform some actions that * don't need to be handled here. * * onClose callbacks need to handle 'closing' the overlay, container * and data. */ function simplemodal_close(dialog) { dialog.data.fadeOut('fast', function () { dialog.container.hide('fast', function () { dialog.overlay.slideUp('fast', function () { $.modal.close(); showFlash(); if($.fn.exitpopup.options.cookieOnClose){ createCookie($.fn.exitpopup.options.cookieName, "1", "5"); } //$.fn.exitpopup.modelDlgShown--; }); }); }); }; jQuery.checkSubmitted = function () { return readCookie($.fn.exitpopup.options.cookieName) == "1"; }; jQuery.trackSubmit = function () { createCookie($.fn.exitpopup.options.cookieName, "1", "100"); /* name, value, days */ }; $.fn.exitpopup = function (options) { if (this.length > 0) { var opts = $.extend({}, $.fn.exitpopup.defaults, options); $.fn.exitpopup.options = opts; $.fn.exitpopup.modelDlgShown = 0; opts.myTime = new Date(); var item = $(this[0]); $(document).mousemove(function (e) { var x = 0, y = 0; if (!e) e = window.event; if (e.pageX || e.pageY) { x = e.pageX; y = e.pageY; } else if (e.clientX || e.clientY) { x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft; y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop; } if (/*$.fn.exitpopup.modelDlgShown < 1 &&*/ (y - $(document).scrollTop() <= 5) && (!opts.checkCookie || !$.checkSubmitted())) { // Launch MODAL BOX if(opts.showOnBounceOnly){ var time = Math.floor((new Date()-opts.myTime)/100)/10; if(time > opts.bounceDelay){ return; } } item.modal({ onOpen: modalOpen, onClose: simplemodal_close }); } }); if (opts.showOnDelay) { setTimeout(function () { if (!$.checkSubmitted() && $.fn.exitpopup.modelDlgShown < 1) { // we check the modelDlgShown variable value so that if the user triggered the dialog going out the window, it won't be shown second time on timer event item.modal({ onOpen: modalOpen, onClose: simplemodal_close }); }}, opts.delay * 1000); } } return this; }; $.fn.exitpopup.defaults = { checkCookie: true, // if true, the dialog won't be shown when the cookie is set, if false - the dialog is shown always when the user goes up the browser window cookieName: "pp_msg", cookieOnClose: true, // if true, the dialog is shown to the user once and a cookie is set to prevent second popup showOnMouseout: true, // if true, the dialog is shown on mouse out showOnBounceOnly: false, // if true, the dialog is only shown if the user leaves the page fast showOnDelay: false, // if true, the dialog pops up after the specified amont of time delay: 4, // in seconds bounceDelay: 4 // in seconds }; })(jQuery); А вот это вставлено на странице. <!--Cкрипты для модального окна начало--> <script type="text/javascript" src="popup/js/jquery-1.7.1.min.js"></script> <script type="text/javascript" src="popup/js/jquery.simplemodal.1.4.2.min.js"></script> <script type="text/javascript" src="popup/js/jquery.exitpopup.js"></script> <link rel="stylesheet" type="text/css" href="popup/style/exitpopup.css"/> <script type="text/javascript"> $(function () { $('#exit_content').exitpopup({ showOnDelay: false}); // $('#exit_content').exitpopup(); // - with default options // $('#exit_content').exitpopup({ checkCookie: false, showOnDelay: true, delay: 30 }); // - more options }); </script> <!--Cкрипты для модального окна конец-->