When user close the browser window I want to show fancybox popup with confirm custom message, or my div with my style and image. How I can do it?
With Jquery, you have to bind the beforeunload event to a function.
Try this :
$(window).bind('beforeunload', function () {
// display fancybox popup
});
Related
I have an xpage (viewed via web browser) which has many <xe:dialog...> controls on it, resulting in bootstrap modal dialogue boxes.
I want to run some client-side script when any dialogue is closed.
So I tried ..
$('.modal').on('hide.bs.modal', function() { ...}
However this didn't work, I suspect because when the xpage is loaded there aren't actually any elements with class 'modal', until one is opened. Then a partial refresh injects the relevant HTML.
So I tried running that line above in the event when the modal opens (in the xpages onShow event), but that didn't fire either. I guess the event might be 'when the modal opens but before it's displayed' meaning the elements aren't ont he screen then either.
So I also tried (hack, hack) a setTimeout of 2 seconds to allow the modal to show first, but still no luck.
So .. question is ..
Using xpages bootstrap modals, via the standard xe:dialog control, how can I attach a client-side javascript event whcih will run when the modal is closed / hidden ?
You can use Event Delegation to bind the listener to a parent element of the (non-existing) modals and trigger a function when a click happens on elements matching the .modal selector in that parent element:
$(document).on("hide.bs.modal", ".modal", function () {...});
I do something similar to this, where a button selection on one modal, closes said modal, and then depending on the button that was clicked, opens the next modal. Instead of doing that, could you not run your script in the same way?
var
currentModal = $(this);
//click next
currentModal.find('.btn-close').click(function(){
currentModal.modal('hide');
OTHER STUFF?
EDIT - My full code:
<script type="text/javascript">
$("div[id^='myModal1']").each(function(){
var
currentModal = $(this);
//click next
currentModal.find('.btn-next').click(function(){
currentModal.modal('hide');
currentModal.closest("div[id^='myModal']").nextAll("div[id^='myModal3']").first().modal('show');
});
//click prev
currentModal.find('.btn-prev').click(function(){
currentModal.modal('hide');
currentModal.closest("div[id^='myModal']").nextAll("div[id^='myModal2']").first().modal('show');
});
});
$(window).on('load',function(){
$('#myModal1').modal('show');
});
</script>
Here I have attached screenshot Attached screenshot for window alert popup. This is window popup it will appear while closing browser tab. If i click leave, the tab will close. If I click stay I need to do some other action. Is there any event to handle 'stay' button in this popup?.
Please share your view, Thank in advance.
Regards,
Marutharaj M.
I'd say its hard since there is no stay event for the beforeunload window.
A dirty fix could be to attach a timer to the beforeunload event:
$(window).on('beforeunload', function() {
setTimeout(function() {
$('#stay').text("Yes, you've decided to stay!");
}, 1000);
return "You save some unsaved data, Do you want to leave?";
});
JsFiddle
I'm opening a modal dialog. As soon as i open the modal dialog i will mask the parent window so that none of the click events can be done on the parent window.
But however, i will need to clear the mask once the child window is closed.
Below is the piece of code which will open the dialog and return the opened window reference.
this.contentWindow = openDialog(this.url);
Once i open the content window, i will apply mask on the parent window as below : Till here all is well :)
this.parentWindow.jQuery("div#layerOverlay").css('display', 'block');
But, also i need to register a call back event on the contentwindow when it's closed
this.contentWindow.onunload = function () { restoreIEMask(); };
function restoreIEMask() {
getTopWindow().jQuery("div#layerOverlay").css('display', 'none');
}
The above piece of code works fine in other browsers except in IE11. I tried various ways in attaching the callback on the contentwindow iframe etc. But nothing seems to work.
Can some please suggest how to get out of this situation.
How can I determine if the popup window was opened? E.g. someone clicked on the extension (chrome.browserAction), the window open and I want to show a loading sign inside the popup every time someone does that?
You can register onClicked event listener for browserAction.
chrome.browserAction.onClicked.addListener(function () {
// do what you want
});
You can also listen to window.onload event in popup page.
window.onload = function() {
// do what you want
};
How to make pop-up window with links to hover like a normal tooltip just a mouse could click on the links. How can this be done? mouseenter loses focus when navozhu on the link and the window closes
jQuery(document).ready(function(){
jQuery("span.mod_events_daylink_evn").live('mouseenter',function(){
jQuery("span#"+cone).append(jQuery("div#"+newdiv));
jQuery("div#"+newdiv).css("display","block");
});
jQuery("div.eeee").live('mouseout',function(){
jQuery("div.eeee").css("display","none");
});
});
try qtip
a jquery plugin
http://craigsworks.com/projects/qtip2/
update by thomas guettler: updated URL, qtip2 instead of qtip.