海
function disableAnchor(obj, disable)
{
if (disable) {
var href = obj.getAttribute("href");
if (href && href != "" && href != null) {
obj.setAttribute('href_bak', href);
}
obj.removeAttribute('href');
obj.style.color="gray";
}
else {
obj.setAttribute('href', obj.attributes['href_bak'].nodeValue);
obj.style.color="blue";
}
}
或
var Link_Enabled_Flag = false; // disable links - background process changes this to true when it's done
function Check_Link_Enabled(){ return Link_Enabled_Flag; }
<a href="wherever.com" onclick="return Check_Link_Enabled()"></a>
或
IE和Firefox兼容JavaScript來啓用或禁用一個錨標記
onclick="disableAnchor(this,'verify')"
function disableAnchor(Check_Obj, Check_Id){
var Anchor_id = 's';
thisCheckbox = document.getElementById(Check_Id);
thisAnchor = document.getElementById(Anchor_id);
if(thisCheckbox.checked){
//alert('Y1');
Check_Obj.setAttribute('href',''); //Check_Obj.attributes['href_bak'].nodeValue
Check_Obj.style.color="blue";
//alert('Y2');
}
else{
//alert('N1');
var href = Check_Obj.getAttribute('href');
//alert(href);
if(href && href != "" && href != null){
Check_Obj.setAttribute('href_bak', href);
}
Check_Obj.removeAttribute('href');
Check_Obj.style.color="gray";
//alert('N2');
}
}
一個格或錨標記 – 2009-12-17 04:23:07
您要禁用它或者把它隱藏 – 2009-12-17 04:23:54
什麼做哪些你的意思是「禁用」?我假設你不希望用戶能夠點擊它並導航到它的目標。你是否還需要防止右鍵單擊「在新窗口/選項卡中打開」? – Annabelle 2009-12-17 04:25:00