You can set the true and false of the Disabled attributes of the hyperlink to determine whether the hyperlink can be clicked.
For example:
<a herf='http://www.baidu.com' onclick='return click(this);' disabled='ture'>bai du</a>
The above means that you don't want the hyperlink of baidu to take effect, but if you don't make any constraints or judgments when clicking, you will naturally jump to Baidu page when you click baidu. This is the bug of the disabled attributes of the hyperlink in html
You can add the following js constraints to determine whether the hyperlink can be used
<script language='javascript'> function click(obj) { if(obj.disabled) { return false; } return truth; } </script>The following bug solution provided by Microsoft:
With the help of global variables, other buttons are used to change the disabled attributes to obtain the effect of disabling attributes.;
BUG: The DISABLED property does not disable hyperlink
Although the DISABLED property is set to True a hyperlink is as follows,
<a DISABLED="true" href="http://www.microsoft.com/" rel="external nofollow" rel="external nofollow" >Where do you want to go today?</a>
The user can still click the hyperlink and then Internet Explorer navigate to the selected page.
To resolve this issue, set the onclick event that returns true or false to the hyperlinked hyperlink based on the current execution context. In the following code, set the global Microsoft JScript variable value to true or false, click on the button. The DISABLED property of the target hyperlink object is updated so that it can correctly communicate its disabled state, other objects and write functions on the script page.
<html> <head> <title>Workaround for DISABLED Attribute Problem</title> <SCRIPT> var canNav = false; function canNavigate() { return canNav; } function load() { document.all("btn1").innerText = "Link status == " + canNav; } function setNavigate(linkObj, canNavParam) { if (linkObj != null) { if (canNavParam == false) { linkObj.disabled = true; } else { linkObj.disabled = false; } canNav = canNavParam; } } function updateBtnStatus(btnName) { var btn = document.all(btnName); if (btn != null) { document.all(btnName).innerText = "Link status == " + canNav; } } </SCRIPT> </head> <body onload="load();"> <a id="lnk1" disabled=true href="http://www.microsoft.com/" rel="external nofollow" rel="external nofollow" onclick="return canNavigate();">Click here</a><p> <button id=btn1 onclick="setNavigate(document.all('lnk1'), !(canNav));updateBtnStatus('btn1');"> </button> </body> </html>