You can put a hash #servicosN
(where N
is the link number) in the URL and use window.scrollTo
to scroll the screen to the menu and fire a click
in the menu link. Example of the link:
http://www.clinvetimbituba.com.br/servicos.html#servicos1
And put this script on the page servicos.html
:
document.addEventListener("DOMContentLoaded", function(){
var target = location.hash; // verifica se tem hash na URL
var linq = $("ul.nav-tabs li a[href$='"+target+"']"); // link que contém a hash
if(target && linq.length){
setTimeout(function(){
// distância do menu ao topo menos altura do nav
var top = $(".sidebar").offset().top - $("#main-nav").height();
window.scrollTo(0, top); // rola atela até o menu
linq.trigger("click"); // dispara o clique
}, 500);
}
});
then, I appreciate the attention, but in fact what I need is to have a link that opens the service page already with the selected service open, for example if I am on the home page and put a link to the "service 2" there in case load the service page already with the "service 2' active
– RJacques
I know... I can do that, but see if the code above already solves a part.
– Sam
ball show, function straight, now just need to see how to open the page already in the specific service
– RJacques
Blz... This first part working is already important. Now I will do the second part.
– Sam
What would the default URL look like? For example, the hash #servicos scrolls the screen to the menu, and the menu link? Type: http://www.clinvetimbituba.com.br/servicos.html#servicos,link1
– Sam
I think more or less that same type clinvetimbituba.com.br/servicos.html#service1 clinvetimbituba.com.br/servicos.html#service2 . . . clinvetimbituba.com.br/servicos.html#service10
– RJacques
See now if it works.
– Sam
sensational, worked perfectly, without words to thank the time and effort spent in helping. how much I owe you even rssss very grateful, att Richardy
– RJacques
Cool guy! see if you can thank marking in the answer. Abs!
– Sam