zoukankan      html  css  js  c++  java
  • 阻止超链接进行跳转

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <script>
            function f1(){
                alert("hello world");
                return false;
            };
        </script>
    </head>
    <body>
        <!-- 第一种方法 -->
        <a href="http://www.baidu.com" onclick="return f1()">百度</a>
        
        <!-- 第二种方法 -->
        <a href="http://www.baidu.com" id="baidu">百度</a>
    
        <script>
            document.getElementById("baidu").onclick = function(){
                alert("hello world");
                return false;
            }
        </script>
    </body>
    </html>
    <!-- 不管是哪种方法,只要在处理函数中返回的是return false就可以了 -->
  • 相关阅读:
    css圆,背景,img填满等样式
    MySQL双日志
    MySQL分层和查询数据的流程
    ZJNU 2345
    ZJNU 2342
    ZJNU 2340/2341/2343
    ZJNU 2235
    ZJNU 2226
    ZJNU 2212
    ZJNU 2208
  • 原文地址:https://www.cnblogs.com/zengsf/p/10304642.html
Copyright © 2011-2022 走看看