I am currently building a website containing lots of links to different sections of my website (also known as navigation). Lets call those links and their corresponding pages link1, page1 , link2, page2, link3, page3 etc.
The general code for them is this:
<a href="/page1.html">Link1</a>
<a href="/page2.html">Link2</a>
<a href="/page3.html">Link3</a>
I want the user to click each link to move to the corresponding webpage and it works as supposed to. The problem is that I want the links to do nothing when the user is on the same page as the link they clicked (meaning it will only reload the page). Let me make this clear by using an example:
Current use: User is on page1. User clicks on link1. The browser will reload page1.
Desired use: User is on page1. User clicks on link1. The browser will do nothing.
TL;DR Essentially I am searching for an if clause. I have read there is no if clause in HTML simply because it's a markup language but what is another way to implement this? Thanks for your help.
tag instead). I wouldn't do either though - let the browser handle it the way it works on every other site; making your site the exception in this way will only make the usability worse.
– Iain Collins Oct 29 '12 at 10:09