How to differentiate refresh page and close page function onunload - javascript

I need a help with this function onunload.
What I want is to differentiate those events close window and refresh page on Internet
Explorer and Firefox because on Google Chrome work fine.
To explain the issue, when I close a window and refresh a page on Internet Explorer or Firefox the function onunload is called; but in Google Chrome, only when you close windows.
Also I use the event onbeforeunload but the same issue occurs.
So the question is, how can I differentiate those event in Firefox and Internet Explorer?
Is this possible?
I will be grateful with your help or some information about this issue.

Related

Redirect to a new page using Browser or Tab Close Event in (Chrome, Firefox and IE) All of them

Please do not mark this as duplicate, as this is not being answered completely in any single post. also no recent working solution for latest browsers is found.
My Question is as under, i am using Asp.net C#, and the code should work on client-side preferably.
Is it Possible to Catch Browser/Tab Close Event for Non IE Browsers (ex. Chrome, Firefox) Current Versions [Version 81+ for Chrome (64-bit)], and Execute navigate to logout page.
The code which i tried for Chrome primarily is as below.
window.addEventListener('beforeunload', function (e) {
e.preventDefault();
e.returnValue = 'this is cuctom message';
window.location.href = "~/logout/Logout.aspx";
});
Now when i use above code in IE, it gives me message like
the problem which i am facing with above code is.
On Every link click this message is called in IE, along with tab close too, and i want to call this message only on tab or browser close.
for Chrome though, above code is called only on link navigation, but not redirected to logout page, and not on browser close.
I am stuck in this activity, with no way forward, can anyone please help me out with a way towards solution to this issue.

How to check if some IE window is already opened by javascript within that window

our web app doesn't support IE but customer wants to use call center functionality which is only supported in IE due to activeX control of call center.
As a work around, when user clicks on call button in chrome, web app opens the callCenter.html page in IE by using URL Alert protocol , and that callCenter.html page starts the initialization of activeX control for further operations. So far its OK.
Problem is, if callCenter.html window is already opened in IE, and user clicks again on call button in chrome, it opens another window of callCenter.html in IE, which results in activeX control initialization again and here it gets malfunctioning, since that activeX control is already loaded and running in previous IE window.
So please suggest, if there is some way, by which we can detect if callCenter.html window is already opened in IE, and if its already opened, it should update the calling parameters for call center.
Many thanks for your kind suggestions

open IE browser by default

I created a web site where I would like to have 1 of the button of my menu navigation to open the internet explorer browser. Since the URL I am pointing for this specific button can only be view with IE and not with Chrome, Firefox etc... Which mean if someone is using Chrome for example and want to access this specific link by clicking on it it will open IE browser and see the content. This is feasible? thanks in advance
No, this is not feasible.
Opening in another browser is totally user side. You would have to alert the user that this page is best viewed in Internet Explorer and leave it up to them to download/open Internet Explorer to view it.

onClick event problems with Internet Explorer 9

I am having sporadic issues with fullCalendar and the click hook in Internet Explorer 9 (this is not an issue in FireFox, Chrome or Opera it seems).
The function I have attached to the click hook when a user clicks an event will only trigger if I first launch the developer console in Internet Explorer and refresh the page. I can then close the console again and use the page as normal, but if I return 24 hours later, I will have to repeat this step to be able to use the functionality again.
My Internet Explorer settings appear fine, as this is not a problem with just this one machine, but also with 5 other machines I have tested this on.
sounds like there is a console.log() included but without any code provided we can only take a guess.

cross-browser Onunload and Onbeforeunload ? (particularly opera 11)

I have a form and I must notice user with alert() on exiting page while there are data in the form that had not been send.
I've read that opera has a lot of problems with this. Opera 11 that is, because I need take into account only last version.
So again, the alert should display on refresh, closing a tab, or closing whole browser.
It would be nice to set event directly to the <form> element that would be launched on anything that leads to destroying this element.
Opera does not yet support onbeforeunload. Opera's onunload support is incomplete - for example, it does not fire when you close a tab, or close Opera. As far as I know, while you can use onunload to show a warning if a user clicks a link to navigate away from a page with an unsaved form, there is no way you can prevent the navigation from happening when the unload event fires.
What I would do here is to listen for the onbeforeunload event, make it work in other browsers and wait for Opera to catch up. Whether it will be in Opera 12 or 13 or 15 I don't know, but when onbeforeunload is implemented it will work like it does in other browsers already.
The Disable Close will not help you yet because Opera does not support window.onbeforeunload at the moment. It will be supported in some future version. For now, Opera 11 doesn't implement it.
onbeforeunload is now supported since Opera 15 !
The JQuery framework is only a condensed Javascript language so it depends entirely on the browser you use, no magic here.

Categories

Resources