I\'m using fancy box to create a popup and load another page on it using an iframe. here is my code
This works for me...
<script type="text/javascript" src="../../js/jquery-ui.js"></script>
<script src="../../js/fancybox-2.1.5/jquery.fancybox.js" type="text/javascript"></script>
<script src="../../js/fancybox-2.1.5/jquery.fancybox.pack.js" type="text/javascript"></script>
<link href="../../js/fancybox-2.1.5/jquery.fancybox.css" rel="stylesheet" type="text/css" />
<script lang="javascript">
var J$ = jQuery.noConflict();
function SelectAndClose() {
txtValue = document.getElementById('<%= _browseTextBox.ClientID %>').value;
window.returnValue = txtValue.value;
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
// At least Safari 3+: "[object HTMLElementConstructor]"
var isChrome = !!window.chrome && !isOpera; // Chrome 1+
var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
if (isIE == true) {
//alert("iexcplorer");
parent.J$.fancybox.close();
//document.getElementById("closeFancyInternet").click();//For IExplorer
}
else {
//alert("another one");
document.getElementById("closeFancy").click(); //For Firefox
}
return false;
}
function closeBrowsing() {
document.getElementById("closeFancy").click();
window.close();
return false;
}
</script>
If you want to check your browser must see this link: http://jsfiddle.net/9zxvE/383/
SIMPLE solution, find link to close (it have a class fancibox-close) and do it in 6 seconds (or 6000 miliseconds)
setTimeout(function(){
$('.fancybox-close').click();
}, 6000);
Use event close button of fancybox:
document.getElementsByClassName("fancybox-item fancybox-close")[0].click();
I had to use parent.jQuery.fancybox.close()
with my Drupal site to get this to work properly.
Because of my close button has different functions: close popup, and close fancybox. It needs to use e.stopPropagation() to stop bubbling event;
$('.close-btn').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).parent().hide();
$.fancybox.close();
});
You can use inline call
<input type="button" onclick="$.fancybox.close()" value="CloseFB" />
Or either you can use function called
<script>
function closeFB() {
// Before closing you can do other stuff, like page reloading
$("#destination_div").load("?v=staff #source_div_with_content");
// After all you can close FB
$.fancybox.close();
}
</script>
<input type="button" onclick="closeFB()" value="CloseFB" />
Call function in onClickevent