0

I'm opening a new html file on button press using this:

window.location = "menu.html";

I want to go back to the index.html file in my "menu" activity after a button press. I tried using

window.location = "index.html";

But it creates a new screen and if I click the return buton to go to my homepage it returns to the previous activities. Also

    window.opener.location = '/redirect.html';
    window.close();

Doesn't work. So how do I close the menu activity to go back to my main activity.

PS: should I use window.location or window.location.href to open new html file

Thanks in advance!

Daan Seuntjens
  • 880
  • 1
  • 18
  • 37

2 Answers2

0

Try using window.open("menu.html", "menu"). In addition to opening the file you can pass in a second parameter to the .open method and the next time you want to open the menu.html file you can using window.open("menu.html", "menu") it will open the already opened file in the browser.

https://developer.mozilla.org/en-US/docs/Web/API/Window/open

Abu Khadija
  • 61
  • 1
  • 4
  • This is opening a screen but its stretched out and on the top its showing my path to the file. Could work with some tweaking and changing the dimentions of my images but I found a simpeler solution. – Daan Seuntjens Mar 15 '18 at 14:35
0

I fixed it using

    history.go(-1);
    navigator.app.backHistory();

sugested in this answer: Phonegap - navigator.app.backHistory() not working on HTML back button

Also the href on the end of window.location.href is used for links so you should use just window.location

Daan Seuntjens
  • 880
  • 1
  • 18
  • 37