日期:2014-05-17  浏览次数:20641 次

<a>标签不可用???
我这里有个<a>标签

<a href="http://www.baidu.com">baidu</a>

如何设置这个标签不可用

a是没有disabled属性的,但是古怪的IE却支持,火狐不支持

期待效果如下:



------解决方案--------------------
用JS控制。。
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>

</head>

<body>
<a href="http://www.google.com/" id="demo">GOOGLE</a><button id="btn_enable">Enable</button><button id="btn_disable">Disable</button>
<script type="text/javascript">
var demo = document.getElementById('demo');
document.getElementById('btn_enable').onclick = function() {
    demo.style.color = '';
    demo.onclick = null;
}
document.getElementById('btn_disable').onclick = function() {
    demo.style.color = '#CCC';
    demo.onclick = function() {
        return false;
    }
}
</script>
</body>
</html>

------解决方案--------------------
页面加载成功后,把a的href属性删除
或者
禁止a的默认事件。
------解决方案--------------------
没看到你要什么效果……,直接href='#'不行?