Can I update window.location.hash without having the web page scroll?

To change the hash without having the page reload/scroll, you can now simply use html5 history.pushState. history.pushState(null,null,’#hashexample’); It’s supported by all the major browsers: http://caniuse.com/history MDN: https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history#The_pushState().C2.A0method Also note that the last url parameter we’re using here can be any url, so it’s not limited to hashes.

How to disable Browser back button in Angular 2

Not sure if this is already sorted, but posting the answer nonetheless, for future references. To tackle this, you basically need to add a listener in your app-component and setup a canDeactivate guard on your angular-router. // in app.component.ts import { LocationStrategy } from ‘@angular/common’; @Component({ selector: ‘app-root’ }) export class AppComponent { constructor( private … Read more

browser back acts on nested iframe before the page itself – is there a way to avoid it?

I’ve found the answer to my problem guess it could be useful for others out there. The problem was with the way i assigned new URLs to my Iframe, i used Jquery so it looked something like that: $(‘#myIFrame’).attr(‘src’,newUrl); When assigning the URL in that manner it adds a new entry to the browser’s list … Read more

PhoneGap – android exit on backbutton

You need to wait for the device to be ready to add the event listener: document.addEventListener(“deviceready”, onDeviceReady, false); function onDeviceReady(){ document.addEventListener(“backbutton”, function(e){ if($.mobile.activePage.is(‘#homepage’)){ e.preventDefault(); navigator.app.exitApp(); } else { navigator.app.backHistory(); } }, false); }

How to change color of back button on NavigationView

You can use the accentColor property on the NavigationView to set the back button color, like in this example: var body: some View { NavigationView { List(1..<13) { item in NavigationLink(destination: Text(“\(item) x 8 = \(item*8)”)) { Text(String(item)) } }.navigationBarTitle(“Table of 8”) }.accentColor(.black) // <- note that it’s added here and not on the List … Read more

How to exit when back button is pressed?

In my Home Activity I override the “onBackPressed” to: @Override public void onBackPressed() { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } so if the user is in the home activity and press back, he goes to the home screen. I took the code from Going to home screen Programmatically