js onclick="return test()"事件返回值,对有些事件,会影响默认动作的执行。如:onclick和onsubmit

onclick="return test()"事件返回值,对有些事件,会影响默认动作的执行。如:onclick和onsubmit
<body>
<!--事件返回值,对有些事件,会影响默认动作的执行。如:onclick和onsubmit-->
<!--多用于表单提交-->
<a href="http://www.baidu.com" onclick="return test()">baidu</a>
</body>
</html>
<script type="text/javascript">

    function test(){
        if(window.confirm("要打开吗?")){
            return true;
        }else{
            return false;
        }
    }
</script>

 

posted @ 2016-01-26 20:19  gyz418  阅读(1282)  评论(0)    收藏  举报