这应该可以很好地禁用单个标题:
<a href="service.php" title="services for cars" onmouseover="this.title='';" />
如果你以后需要标题,你可以恢复它:
<a href="service.php" title="services for cars" onmouseover="this.setAttribute('org_title', this.title'); this.title='';" onmouseout="this.title = this.getAttribute('org_title');" />
这种方式虽然不是通用的.. 要将其应用于所有锚点,请使用这样的 JavaScript 代码:
window.onload = function() {
var links = document.getElementsByTagName("a");
for (var i = 0; i < links.length; i++) {
var link = links[i];
link.onmouseover = function() {
this.setAttribute("org_title", this.title);
this.title = "";
};
link.onmouseout = function() {
this.title = this.getAttribute("org_title");
};
}
};
Live test case.
编辑:将相同的标签应用于更多标签(例如<img>)首先将代码的核心移动到一个函数:
function DisableToolTip(elements) {
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
element.onmouseover = function() {
this.setAttribute("org_title", this.title);
this.title = "";
};
element.onmouseout = function() {
this.title = this.getAttribute("org_title");
};
}
}
然后把代码改成:
window.onload = function() {
var links = document.getElementsByTagName("a");
DisableToolTip(links);
var images = document.getElementsByTagName("img");
DisableToolTip(images);
};