这是看过孝祥书上的代码后自己写的,可是为什么我按住shift键点击百度图标
仍会触发showSrc()事件呢? 这个例子的意思是当按住shift键后,点击百度图标,就不再显示图片地址了。请大家帮忙看看,我的代码错在什么地方了?我怎么找,也找不出错误。
<html>
<head>
<script type="text/javascript">
function showSrc() {
if(window.event.srcElement.tagName == "IMG") {
alert(window.event.srcElement.src);
}
}
function checkCancel() {
if(window.evnent.shiftKey == true) {
window.event.cancelBubble = true;
}
}
</script>
</head><body onclick="showSrc()">
<img src="baidulogo.gif" onclick="checkCancel()">
</body></html>
仍会触发showSrc()事件呢? 这个例子的意思是当按住shift键后,点击百度图标,就不再显示图片地址了。请大家帮忙看看,我的代码错在什么地方了?我怎么找,也找不出错误。
<html>
<head>
<script type="text/javascript">
function showSrc() {
if(window.event.srcElement.tagName == "IMG") {
alert(window.event.srcElement.src);
}
}
function checkCancel() {
if(window.evnent.shiftKey == true) {
window.event.cancelBubble = true;
}
}
</script>
</head><body onclick="showSrc()">
<img src="baidulogo.gif" onclick="checkCancel()">
</body></html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货