Topic: How to hide the name of a section inside URL?
Tomek Makowski staff answered 5 years ago
Try out this solution
window.addEventListener('hashchange', () => {
history.pushState("", document.title, window.location.pathname);
});
Regards
Tomek Makowski staff answered 4 years ago
hmm strange, could you show your code in the snippet code editor
https://mdbootstrap.com/snippets/
My code looks like this. Be sure that you have your js code in proper position. Moreover it only works when you click in the link which have a href attribute with hashtag sign
<body>
<a href="#first">first</a>
<div style="height: 120vh"></div>
<section id="first" style="height: 30vh">dddd</section>
<!-- jQuery -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<!-- Bootstrap tooltips -->
<script type="text/javascript" src="js/popper.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<!-- MDB core JavaScript -->
<script type="text/javascript" src="js/mdb.min.js"></script>
<!-- Your custom scripts (optional) -->
<script>
window.addEventListener('hashchange', () => {
history.pushState("", document.title, window.location.pathname);
})
</script>
</body>
Regards
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: Other
- MDB Version: -
- Device: Any
- Browser: Any
- OS: Any
- Provided sample code: No
- Provided link: Yes
Tomek Makowski staff commented 5 years ago
hi
Unfortunately link doesn't work
Regards
pawled commented 5 years ago
It's just example. What I mean.
I want to hide last part of address. The name of section (one page website after scrolling).
Tomek Makowski staff commented 5 years ago
You can always use link shortener like
https://app.bitly.com/
pawled commented 5 years ago
You don't understand. I'm talking about one page website navigation. When I click scrolling link, it adds section name at the end of address. I want to hide this part (#this_part). Address should always looks like https://example.com/