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>
  • 相关阅读:
    Poj(1703),种类并查集
    Poj(2236),简单并查集
    Poj (3239),m皇后问题
    Poj(1521),哈夫曼编码
    NYOJ(680),摘枇杷,(暴力,或者二分搜索)
    NYOJ(42)欧拉图
    数集合有多少个TOJ(2469)
    HDU(1016),打素数环
    HDU(4394),数论上的BFS
    Poj(2225),三维BFS
  • 原文地址:https://www.cnblogs.com/Tanwheey/p/14943730.html
Copyright © 2011-2022 走看看