onclick return and javascript
onclick return and javascript
感谢任何能帮助我的人!
我有一段文字,代码是:
<a onclick="return showPic(this); mostrarespectacular()" href="Imatges/productosnuevos/urbano01.jpg">  Circuito Espectacular Barcelona</a>
脚本是:
<script type="text/javascript">
function showPic (whichpic) {
if (document.getElementById) {
document.getElementById('imgContenedor').src = whichpic.href;
if (whichpic.title) {
document.getElementById('imgDescripcion').childNodes[0].innerHTML = whichpic.innerHTML;
}
return false;
} else {
return true;
}
}
</script>
<script type="text/javascript">
function mostrarespectacular() {
div = document.getElementById('circuloespectacular');
div.style.display = 'inline';
}
function cerrarespectacular() {
div = document.getElementById('circuloespectacular');
div.style.display='none';
}
</script>
我的问题是,第一个函数运行得很好,但第二个函数(必须显示div)运行得不好。你知道我做错了什么吗?谢谢
您在第一次函数调用后从onclick返回。去掉它,你就应该没事了。
"return"是在调用showPic()函数后从脚本中分支出来的。删除return或将其放在"mostrarespectacular()"调用之前,或将其移动到末尾,等等。
相关文章:
- JavaScript and LiveView (TIBCO Live Datamart)
- Javascript and onMouseOver
- javascript and css firefox issue
- geolocation with javascript and ruby on rails
- Javascript and the DOM issues
- Javascript and Java Communication
- Javascript and Knockout
- Javascript and Css: Height does not change
- javascript and Internet Explorer 8
- Javascript and html, UI construction
- Javascript and Lightbox
- javascript and css styling
- JavaScript and URL parameters
- Javascript and singleton pattern
- Javascript and Ajax Calls
- OAuth, javascript and many URI's
- Javascript and AJAX post method
- javascript and web services WSDL
- javascript and webview in android
- Javascript & and | symbols