My application is opened in an external browser.
there possibility that when a person returns to the application will automatically close?
Thank you,
No. The browsers are all "sandboxes". They can't detect when you return to your application.
The best you can do is in JavaScript, ask your window to close when you think the user is doing working in that tab (but the users can decline to close in some browsers):
function closeWin() {
myWindow.close(); // Closes the new window
}
Related
On the application I am working on, the state of all items is saved in the backend API database. The Vue state has a boolean to let the user know when the state is dirty (synced with backend) or not. So the user can hit ctrl + s and save whenever they make changes.
An issue I have is that when a user hits refresh, they could lose their work. So I implemented a feature to open a dialog to alert the user they're about to lose their work if they hit f5 when the state is dirty. This was done with the "beforeUnload" event listener.
But I also need security for the users work when they hit the back button.
I can detect it with this code:
window.addEventListener("popstate ", (e) => {
});
But I can't figure out how to handle the event correctly and have the user cancel the pressing of the back button. Is this even possible?
Thanks.
This is not reliably possible in browsers, regardless of the framework you are using; see https://stackoverflow.com/a/12381610/5471218 for a similar question.
That said, I strongly advise against interfering with the user's browser interaction that way. If you want to protect users from losing data, you could save it to local storage until you have confirmation that the data has been stored in the backend.
I have a NodeJs Express app and when a particular user goes to a page/route would like to identify and display if another user is currently viewing the page as well. So for example it would say "Jerry currently viewing this page" and someone else goes there.
Is there any easy/lightweight way to do this?
First off, with a regular web page, the server only knows who and when a page was requested. It doesn't, all by itself, know whether that user is still viewing that page or not. The user could have closed the browser, typed something else in the URL bar, the computer could have gone to sleep, etc...
Second off, even if the page is still being displayed in the browser, you can't know if someone is actually there at the computer or not. The best you could do is to try to keep track of activity in that web page (last mouse click, recent mouse movements over the web page, etc...).
Then, to even have any idea of the web page is even still open in the browser, you need some way of tracking that notion. There are two possibilities I can think of.
You can have some Javascript in the web page that regularly (say once every few minutes) sends a small little ajax call to your server that basically just says "I'm still here". This wouldn't know immediately when they left the page, but if the server finds that the usual every few minutes ajax call didn't come, then the server can change the status of that user on that page to not there any more.
If that web page makes a webSocket or socket.io connection to the server and keeps that connection alive, then whenever the browser closes or the user closed that tab or navigates to another page, that webSocket or socket.io connection will get automatically closed and the server will be notified that the socket got closed. Using this technique, the server can know pretty much right away when the user leaves the page.
A Lotus notes doucment is oepned in browser from a notes view. This is opened using xpage and after save and exit like to automatically refresh uiview to show the back end changes.
Any ideas how to accomplish this?
The application is running on 8.5.2 client and only few documents are opened in browser.
Your Save action could call (backend) view.refresh() method, but it is not recommended. This can lead to serious performance problems (semaphore locks on all http threads).
As sais in one of your comments it is opened by a new tab. In fact that makes it a bit easier. When you can create a client side action that mimics the opening of the document by just calling window.open() you can call its parent ( the page you're window.open originated from) to do something.
something like window.opener.document.getElementById()
( you have to google yourself for the correct syntax ).
This would give you the opportunity to call a partialrefresh on your view just before the child browser window is being closed.
Whats the standard way to detect the browser window close event in any standard browser? By standard I mean something that sites like Google or Facebook implement when the "keep me signed in" checkbox is unchecked. I have an interactive website in place where theres an Instant Messaging module and I need to inform the other user that the partner has logged out.
Thanks in advance.
The keep me signed in links are managed via cookies and cookie timeout lengths.
One approach to doing something like this is to have the browser make an async ajax call every (1 minute) to your server so you know they are still logged in. If you dont receive one of these calls within say 90 seconds you can say they are logged out.
This approach would also catch cases where for example their connection went or their computer crashed.
I need to open a webpage from a BlackBerry application. I don't want to use a hyperlink so that users have to navigate to the blackberry browser application.
So, I basically need a full screen where the content of that particular page can be loaded just like a browser.
Is weblinks the answer to what I need or do I need to just invoke a browser session?
Thanks!
For BlackBerry applications you can use
BrowserSession session = Browser.getDefaultSession();
session.displayPage(url);
It will automatically open the browser with the given url. It's basically invoking the browser in your application context, so pressing the back button will take the user back to your application.