'JavaScript I want to navigate to another page
I need to know what to do exactly. I'm editing a template and I want to add some items in the nav-bar to redirect me to an outer page. it works fine the full size page but in mobile size it don't it only move me in the same page. this is the function that responsible for the operation:
var OnePageNavigation = function() {
var navToggler = $('.site-menu-toggle');
$("body").on("click", ".main-menu li a[href^='#'], .smoothscroll[href^='#'], .site-mobile-menu .site-nav-wrap li a", function(e) {
e.preventDefault();
var hash = this.hash;
$('html, body').animate({
'scrollTop': $(hash).offset().top
}, 600, 'easeInOutExpo', function(){
window.location.hash = hash;
});
});
};
and this is the template: https://technext.github.io/banker/index.html this is the source: https://github.com/technext/banker
what can I add to the function or the code to allow me to navigate to outer pages?
Sorry if my explanation was bad my English is not the best
Solution 1:[1]
All you need to do is to set the body's scroll-behaviour to smooth in CSS. Then set the href of the navbar links to #section_name.
There is a w3schools documentation here. Fare thee well.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
