B4J Question [ABMaterial] Previous page is closed when user click back arrow in the WEB Browser

Ganiadi

Active Member
Licensed User
Longtime User
Dear All,
I am not sure why my previous page is closed when user click back arrow in the web browser, so we need to click refresh again
is there any way to prevent this ?
Please help
 

Harris

Expert
Licensed User
Longtime User
is there any way to prevent this ?
Stop clicking the browser back arrow....
The browser will go back to the history (page) from which it came from... Default behavior... It MAY be outside your control, since the browser received the event click, and not your app... Of course, I was wrong once before - once... (ok, twice...)

While development in debug mode, I often click the refresh page of the browser to load my latest corrections.
Seems to me, there is some way to prevent the user - and trapping the back key - from going back (ie. before saving the data - for example) - but I may be confused with B4A and B4J.... since I work heavily in both....
 
Upvote 0

rbirago

Active Member
Licensed User
Longtime User
I noticed this problem using Chrome, but instead using Edge there are no problems.
I tried to add
B4X:
page.DisableBackButton=True
in Websocket_Connected and/or in ConnectPage, but the browser back button is not disabled.
This problem is really annoying, because people is used to normally click the browser back button in the standard navigation.
Any other suggestion?
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
There is no real 'solution' for this problem. Browsers do everything possible to prevent programmers to disable the back button. Looks like Edge is behind and Chrome already 'solved' the hack used in ABM.

We do not use page.DisableBackButton=True in our WebApps. But we do not experience the problem the OP sees: we do not need to refresh, it happens automatically.

Alwaysbusy
 
Upvote 0

rbirago

Active Member
Licensed User
Longtime User
I understand...but really it is not true that in Chrome the refresh is automatic: the user have to refresh the page manually. The up-right bullet becames red.
As opposite in Edge and Firefox no problem using tha browser back-arrow button.
 
Upvote 0

MichalK73

Well-Known Member
Licensed User
Longtime User
This is indeed where I'm puzzled. I don't see that behaviour in our Web Apps.
I think last December @alwaysbusy I asked you that I just had a very similar problem but in the mobile version on iOS, ih standard Safaria browser. There too, at some point when the user gave back it would go back to the previous one but it would disconnect the websocket and you had to refresh the page. I stupidly solved the problem, that when I had a mobile version of the page I added a button on the 'Back' page and people started to click like that instead of back. But it's a prosthesis.
I had no problem with computer browsers though. I suspect the cause lies somewhere else in the user code.
 
Upvote 0

rbirago

Active Member
Licensed User
Longtime User
My doubt was in some silly mistake in my application (copied from original samples), but then I tried the same behavior on one of the sample apps given.
In this case I have used the sample app of login WITHOUT any additional implementation.
Using Edge I have performed the login and from the page given after a valid login I used the Edge's back button: all is ok.
Repeating the same steps in Chrome after the Chrome's back button the connection is lost.
See the original sample app attached.
 

Attachments

  • lesson2.zip
    32.9 KB · Views: 115
Upvote 0

mangyun

Member
hi all, is there any workaround for this ?
for me, the problem exists on chrome. edge ok, just like @rbirago
when I clicked the refresh button, all is well.

if no workaround, I'll have to tell my users to always watch for the connected indicator, if its red, just press the refresh button.
 
Upvote 0

rbirago

Active Member
Licensed User
Longtime User
I have added in the app a back menu item controlled by the program. I've suggested users to use it instead of standard "back"... and taking a look to connection indicator. No other workarounds for me.
 
Upvote 0

vp2020

Member
Licensed User
In ABMaterial is:

B4X:
page.DisableBackButton=True

Setting page.DisableBackButton=True,
Chrome back button would be disabled only if user clicked the page once,
otherwise the page will go back and connection lost and never auto refresh.

I ask my users use Edge instead of Chrome recently.

Any idea how to give a system alert when web socket was disconnected by back button pressed?
 
Upvote 0
Top