按书上onclick:showPic(this);return false;为什么还是跳转了?
刚开始js学习,按书上onclick:showPic(this);returnfalse;为什么还是跳转了?<!doctypehtml><html><head><titl...
刚开始js学习,按书上onclick:showPic(this);return false;为什么还是跳转了?
<!doctype html>
<html>
<head>
<title>Text JavaScript</title>
<meta charset="utf-8">
</head>
<body>
<a href="../images/images/big_dom (2).jpg" onclick="showPic(this);return false;" title="企划宣传" class="pr"></a>
<a href="../images/images/big_dom (3).jpg" onclick="showPic(this);return false;" title="最新短片" class="video"></a>
<a href="" title="特色产品" class="products"></a>
<a href="" title="店面规划" class="storefront"></a>
<img src="../images/images/big_dom (2).jpg" id="scroll">
<script type="text/javascript" src="../javascript/showPic.js"></script>
</body>
</html>
function showPic(whichpic) {
var source = whichpic.getAttribute("href");
var placeholder = document.getElementById("scroll");
placrholder.setAttribute("src",source);
} 展开
<!doctype html>
<html>
<head>
<title>Text JavaScript</title>
<meta charset="utf-8">
</head>
<body>
<a href="../images/images/big_dom (2).jpg" onclick="showPic(this);return false;" title="企划宣传" class="pr"></a>
<a href="../images/images/big_dom (3).jpg" onclick="showPic(this);return false;" title="最新短片" class="video"></a>
<a href="" title="特色产品" class="products"></a>
<a href="" title="店面规划" class="storefront"></a>
<img src="../images/images/big_dom (2).jpg" id="scroll">
<script type="text/javascript" src="../javascript/showPic.js"></script>
</body>
</html>
function showPic(whichpic) {
var source = whichpic.getAttribute("href");
var placeholder = document.getElementById("scroll");
placrholder.setAttribute("src",source);
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询