tab remembers url when refresh
We have a single page application. And the url looks like below depending on the page that's clicked.
http://aaa.com/#/page1 or http://aaa.com/#/page2 or http://aaa.com/#/page3 .....
However, the tab doesn't reflect the current url . In fact, the tab shows a url that was at the moment I refresh the browser. For example, I was on http://aaa.com/#/page1 and hit F5 key. Then the tab keeps showing http://aaa.com/#/page1 even though I moved to http://aaa.com/#/page2.
Is this at all fixable?
Thanks, Joey
Valitud lahendus
You can set document.title to modify the page title on the fly. This probably is a good idea in case the user is viewing the tab title on the Windows task bar jump list, where they will see much more of it:
document.title = "About Us :: Happy Applications";
You could create an array of titles (or partial titles) corresponding to the various hashes you are loading to streamline it.
Loe vastust kontekstis 👍 0All Replies (8)
I'm not sure I understand your scenario. Is the problem that the new URL is not appearing in the address bar when it should, so Firefox reloads the wrong URL, or that the URL reverts to an earlier page when you reload??
Muudetud
Actually, on second read, it seems that the application works normally unless you reload the page. After a reload, the URL bar is stuck and the hash does not get updated.
What is your code to update the hash in the URL bar? When that code runs, do any errors appear in the browser console (Ctrl+Shift+j)?
Thanks for your reply. The address bar has no problem. Even after a reload, the application works fine. But the TAB (not the url bar) shows the wrong/old url instead of the current url in the address bar.
When I said tab, i meant the tab of the browser.
This doesn't happen on Chrome just fyi
Also, it doesn't have to do with the code because the tab shows the old url even if I manually type in a new url in the address bar and hit enter.
For example, I am on http://aaa.com/#/page1 And I refresh the browser (at this point, the browser tab reflects http://aaa.com/#/page1) And I type in http://aaa.com/#/page2 in the address bar and hit enter. At this point, the tab still shows http://aaa.com/#/page1 (the address bar has the correct url which is what i typed in which is http://aaa.com/#/page2)
Muudetud
Is this page online for viewing by forum volunteers?
I'm not clear on what you mean by the tab.
You could be saying that the tab content is not scrolled to the expected location within the page when you change the address in the URL bar, or the script that should run when the URL is changed is not running.
Or you could be saying that the text on the little tab itself -- normally the window title, absent which the URL is displayed -- isn't updating.
I'm doing a lot of guessing here, so it would be helpful to be able to see the problem first-hand.
If your page is not online but you see the problem in similar applications on other sites, you could link to one of those instead.
Thanks for your reply. This application is not online but the problem is, as you described, the text itself on the little tab isn't updating.
SO, the actual text on the little tab shows http://aaa.com/#/page1 when I am actually on http://aaa.com/#/page2.
However, I think I should just be able to give a certain name on the little tab instead of trying to reflect the current url. Just like this support forum page's tab is showing "tab remembers url when....." instead of the url.
So, this is my new question... How can I name a tab in the code?
Valitud lahendus
You can set document.title to modify the page title on the fly. This probably is a good idea in case the user is viewing the tab title on the Windows task bar jump list, where they will see much more of it:
document.title = "About Us :: Happy Applications";
You could create an array of titles (or partial titles) corresponding to the various hashes you are loading to streamline it.