pushState and router

With pushState enabled how can I check if a route is loaded directly by typing url in browser address bar or is loaded by link click?? I need this to manage the back link in case a route is reached through an external application or by typing the url in browser address bar.

I checked router object properties but I couldn’t understand what properties or methods I could use

Thanks in advance


You can try to check router.history i guess it can be different in these cases

router.history is an array that contains the same values in both cases (route loaded directly by typing url in browser address bar, route loaded by link click).

["/", "/dox/50/"]

Second value is current route.

Why does the router.history contains two routes even when the address is entered in the address bar?
If the previous element in history array is “/” why when I click on the navbar backlink does the router not load the main route “/” (the browser return on start page) ?

У вас View c каким адресом создана?

Same result settings View url properties to “/” or blank
if it can serve I’m using svelte version

/ - это как раз начальный урл, с которым и создается View. Его вы указываете самостоятельно.

Ok, since the router.history contains the same values ​​both reaching the route by typing the url in browser address bar and through the link click, then the question is the same of the first post:

Yeah, I spent a lot of time, for this problem. Finally, just wrote hack inside back link handler function:

this.$f7router.back(’/’, { force: true, pushState: false })

The first string replace browser url (without repload) because push state (in the second string) is disabled.
The second string go back to the home url (’/’) without push state.

UPD. I use the global flag in my application state to check for follow on direct links to internal pages. If the flag is not set, then the user did not visit the home page. )


Thanks for your help but I need some more information.
I suppose you use the code in a function called by a link click event (and therefore you do not use Navbar backLink): but in this case this.$f7router does not return router instance.

Can you enrich your example with more information / code??
Thanks in advance

You,re right.

I have a React project and this.$f7router returning for me router instance in component. You need an instance of the current router.