I use fancybox to open a popup window with a form. At the moment popup comes to life when mouse leaves main page. In order to make this work i have a hidden link tag which i simulate with trigger() function that is clicked in order that link’s href which is forms id with fancybox to come in life. Code as follows:
<a id="trigger" href="#feedback_form" style="display:none"></a>
$(document).mouseleave(function() {
//Triggers popup
$("#trigger").fancybox().trigger('click');
//Popup function
$("#trigger").fancybox({
});
});
Is there any other way to do this?
Option 1 : hidden link and two functions :
1.1 Bind fancybox to selector :
1.2 Then trigger the selector :
Option 2 : hidden link and a single function :
See : JSFIDDLE
Option 3 (recommended): NO hidden link and a single function :
See : JSFIDDLE