zoukankan      html  css  js  c++  java
  • 设置a标签,实现点击跳转页面

    设置a标签的属性target,下面对target属性进行描述:

    跳转在同一个窗口

    1、target="_self",  它使得目标文档载入并显示在相同的框架或者窗口中作为源文档。(此处就是实现你的每次跳转都在同一个窗口的核心点)

    跳转在新的窗口

    2、target="_blank" ,浏览器总在一个新打开、未命名的窗口中载入目标文档

    总结:属性值前面都是英文字符的下划线_ ,别打错了

    方法1:使用onclick事件

    <input type="button" value="按钮"
    onclick="javascrtpt:window.location.href='http://www.baidu.com/'" />

    或者直接使用button标签

    <button onclick="window.location.href = 'https://www.baidu.com/'">百度</button>

    方法2:在button标签外套一个a标签

    <a href="http://www.baidu.com/">
        <button>百度</button>
    </a>

    或使用

    <a href="http://www.baidu.com/"><input type="button" value='百度'></a>

    方法3:使用JavaScript函数

    复制代码
    <script>
    function jump(){
     window.location.href="http://www.baidu.com/";
    }
    </script>
    <input type="button" value="百度" onclick=javascrtpt:jump() />
    // 或者<input type="button" value="百度" onclick="jump()" />
    // 或者<button onclick="jump()">百度</button>
    复制代码

    去掉a标签的下划线

    <style type="text/css">
    a{text-decoration:none;}
    </style>
  • 相关阅读:
    Two Sum II
    Subarray Sum
    Intersection of Two Arrays
    Reorder List
    Convert Sorted List to Binary Search Tree
    Remove Duplicates from Sorted List II
    Partition List
    Linked List Cycle II
    Sort List
    struts2结果跳转和参数获取
  • 原文地址:https://www.cnblogs.com/Tanwheey/p/14943730.html
Copyright © 2011-2022 走看看