This question already has answers here:
Clicking the device back button closes the app instead of going back to previous page
(5 answers)
Closed 7 years ago.
I'm using Ionicframework for my first android application my problem is my application has many tabs and inner pages and user can go through them but when user try to close application the back history pages are repeated on mobile back Navigation button(not the one in the UI header) just like normal browser of android or chrome.
What I want when it's on main page and user press Mobile Back button he should be out of application and don't go through all the tabs which he has viewed previously, as it make sense.
I've tried this but nothing works.
$ionicHistory.clearHistory();
$ionicHistory.nextViewOptions({
disableAnimate: true,
disableBack: true
});
Thank you
$ionicPlatform.registerBackButtonAction(function (e) {
e.stopPropagation();
e.preventDefault();
$window.navigator.app.exitApp();
,101);
The code above registers a back-button action with priority 101 and closes the app on back-button if there's no modal / popup / side menu open. You might want to check something like if ($state.current.name !== YOUR_HOME_STATE_NAME) {.
See also: Documentation of $ionicPlatform
EDIT:
Since you still want to navigate backwards, you can use the $ionicHistory-Service with it's goBack()method.
Related
This question already has answers here:
Is there a way to detect if a browser window is not currently active?
(24 answers)
Closed 4 years ago.
Is there an event I can listen to when a browser tab becomes active.
By becoming active I mean all of the following things:
When user switches to the tab with my website form another tab.
When user switches back to the browser (with tab that contains my website open) from another App.
When user unminimizes the browser (with tab that contains my website open)
Basically when our tab becomes active from any other condition.
You could use the following event for this,
document.addEventListener("visibilitychange", function() {
console.log(`Your page is ${document.visibilityState}`);
});
You can check the browser compatibility of the above here.
This question already has answers here:
Communication between tabs or windows
(9 answers)
Closed 5 years ago.
I have 2 open tabs from same application and same domain: tab1 and tab2, they are not opened from each other I mean I can not use win.open(....) and win.reload() So is there any way to find the tab by name and refresh it. The objective is from tab1 find the tab2 and refresh it automatically. any idea?
I see 2 solutions to your problem:
check if your document focus has changed. You only need to refresh it when tab gets visible again.
register open tabs in a session array and flag them with ajax calls or with server side code if they need to refresh. each page (tab) can check it's flag, refresh itself if needed and clear flag. I will need to know what might trigger the need to refresh for a better approach.
I am developing a SharePoint App that basically launches a form in a Windows 8 application once the action is clicked. This is working perfectly fine. However, once you select this action, you are redirected to a page that basically holds some parameters to launch the app. This page throws a window that asks the user if it's okay to launch the app:
How can I detect if this has been launched or not? Ultimately I'd like to detect if the user hits 'Allow' or 'Cancel' but either scenario will work. I am trying to redirect a user to the parent page once this window has launched (hopefully when the user clicks 'Allow'
Is this possible? I found a helpful thread here: http://support.smartbear.com/viewarticle/55730/
However, this thread is very useful but doesn't give me the answer I need. I've tried using jQuerys .blur and this works(ish). It isn't giving me a consistent response but looks like it's a step in the right direction (if I can't detect the window that launches). I've also tried the following code by using .hover but am receiving inconsistent results.
$(window).hover(function (event) {
if (event.fromElement) {
console.log("inactive");
window.location.href = "http://google.com";
}
else {
console.log("active");
}
});
At the highest level possible, I'm trying to redirect the user once the app is launched.
Thanks in advance for any helpful input.
This question already has answers here:
Prevent user from seeing previously visited secured page after logout
(7 answers)
Closed 6 years ago.
How to disable the browser backbutton after signout / logout for my website. I am using jsp and struts1, i am using this code but this is not working properly (i.e in all pages the browser backbutton is not working but my requirement is was not that one) .
<script>
history.forward();
</script>
Please any one help me.
You don't need to disable the browser back button. You need to expire/invalidate the session when the user clicks logout. Then even if he clicks the back button, your app should detect that this request now comes with an invalid session, and so it would forward him to the login page (as he has no valid session already).
This question already has answers here:
JavaScript, browsers, window close - send an AJAX request or run a script on window closing
(9 answers)
Closed 6 years ago.
I am working on a website, where at a time one admin can login. I implemented this by saving value in database. Now the problem is when current admin forget to logout, the value in database do not change and another admin can't login again. Even this current admin can't login later on, cause the value in database is checked in condition.
I have looked in window.onbeforeload and window.onunload functions, but it only trigger on page refresh etc, not detecting browser close tab/window. I want to detect closing browser tab and call function upon close, so I can change value in database using ajax.
Any help will be appreciated! Thanks
The event you are looking for is onbeforeunload
Use window.uneforeunload which is trigged when tab/window is closed.
Updated
window.onbeforeunload = function (){
// update your database from here before page closed
}
DEMO