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
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.
Questions:
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) ?
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:
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