rammohan.acharyadasa
Posts: 0
Joined: Thu Apr 05, 2012 5:03 pm

how to handle page leave event

Hi
i have i am creating mobile app which will work on ios,android.
when the users clicks navigates to another page, example from pageA to PageB.
i want to handle page left event fo "PageA" to stop palying the html5 audio.
how i can handle page left event on "PageA"

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

how to handle page leave event

Hi!

Not sure I understand you correctly. Do you mean on page A you play audio then after click on this page it stops playing and navigate to page B?

rammohan.acharyadasa
Posts: 0
Joined: Thu Apr 05, 2012 5:03 pm

how to handle page leave event

i have html5 audio player on PageA.
it works great.
the user clicks play icon of the html5 audi it plays music. it is working fine. no issues
there is backbutton on pageA, when the user clicks on the "backbutton" or cliks anythin on the tab (bottom line have 5 tabs to go to other pages etc..) to go to another pages of the App.
i want to sop the audio when the pageA is navgated to any other page. ( the user may click either "Bakbutton" or any one of the tab (bottom i have 5 tabs)
how to achieve this
i am thinking to handle page left( if any such event exists) event of "PageA" , i want to write below code:
$("#myHtml5audio1").pause();
$("#myHtml5audio1").currentTime = 0;
but i am not finding "page left" event to hadle.
how to handle page left evet( or any other event similar to page left so that i can stop palying the audio when the user moves out from the pageA)

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

how to handle page leave event

Just before you navigate, run JavaScript to stop playing the audio.

rammohan.acharyadasa
Posts: 0
Joined: Thu Apr 05, 2012 5:03 pm

how to handle page leave event

which event i need to handle
i know i need to choose "action" as "run javascript"
but for the PageA, which event i need to choose. i tried "unload" it is not firing.
i also tried "page hide" event but it is also not firing.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

how to handle page leave event

Run the JavaScript just before you invoke navigation.

Victor Fagerström
Posts: 0
Joined: Sun Dec 01, 2013 1:03 pm

how to handle page leave event

That means it has to be done manually to every navigation button that leaves the page. Is there a way, such as an event like "beforeleavingpage run javascript", to achieve this with clicking any navigation button that leaves the page?

V

Victor Fagerström
Posts: 0
Joined: Sun Dec 01, 2013 1:03 pm

how to handle page leave event

run javascript on page hide seems to be working for me now, is that the right way to do it?

V

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

how to handle page leave event

Hello!
If Run JS action on page Hide event works the way you need, you can use it.

Victor Fagerström
Posts: 0
Joined: Sun Dec 01, 2013 1:03 pm

how to handle page leave event

Would it be possible to run the JS action BEFORE the navigation away from page happens?
At page Hide event JS action seems to run after navigation is complete or has at least started.

V

Return to “Issues”