4
hello, I am making a code using Typescript and I need to do a check to know which page the user is on, I am doing this check as follows:
const url = window.location.href;
if (url.indexOf("/Menu")) {
alert("aqui")
}
but it’s not working well... when I run the code, go to index ne, at the following url: https://localhost:44390/
and he’s giving me the heads-up, even though he doesn’t have the /Menu. It also appears the alert on the menu page, but is clearly not working as it appears on both pages. Someone there can give me a hand?
The correct one would be to show the alert only in the url https://localhost:44390/Menu
Ask me one more question if you can... When I am on an Index page, in HTML, the url does not appear as follows: https://localhost:44390/Index
, she appears without the /Index
, that is to say: https://localhost:44390/
... then how can I make a code that will check if I am on the index? When I’m on the menu, I can use the same in my example, because it has the /Menu
, but the index has nothing that leaves as specific... as I do?
Great answer, thank you for the explanation, I added one more question related to this in the question... if you can answer it, thank you.
– user149429