Use Ancora and update the page with Javascript

Asked

Viewed 970 times

0

Good morning, I have a html with several tabs, when I do some procedure, I need to update the page, when you return from the upload, I need you to go back to the tab where I left.

I added some anchors, like id of my tabs: <div id="aba1"></div>

now I would need to pass the id of my anchor together with javascript.

I’m using the location.reload() So far, I can use you for that? How can I do?

  • Can you add an example of how these links are made? you can pass a query in the url, like link.html?id=aba1 and read this in javascript. But it would be interesting to describe your problem better because there may be better logic to do this.

  • <a href="#fragment-2"> <div id="fragment-2"> <jsp:include page="casa.jsp" />&#xA;</div>

1 answer

1


And if you wear something like that:

window.location.href = "http://www.meusite.com.br/...?aba=01";

then just change the value of the parameter aba to know which tab should be selected.

Depending on your server-side you can also use in the standard way:

window.location.href = "http://www.meusite.com.br/...#aba-01";

Ai on the server you must identify which the ID selected and put it as active.

  • 1

    I also managed doing like this: window.location.href = '#fragment-2'; window.location.reload()&#So he went to my tab with that id.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.