zoukankan      html  css  js  c++  java
  • meta标签

    摘自w3cschool的图:

    1

    这个标签有一个必需属性和一个可选属性:

    2

    总结下mate标签的作用:

    1、指定当前页面的编码

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    相当于在 dopost() / doget() 方法中设置

    request.setCharacterEncoding("utf-8");
    response.setContentType("text/html;charset=utf-8");

    2、实现定时跳转

    <!-- 使用meta标签实现重定向 -->
    <meta http-equiv="refresh" content="5; url=http://localhost/demo/login.jsp" >

    content属性:

    • 前面是时间值,单位秒;
    • 后面是url路径。

    一般定时跳转都会结合js实现秒数的变化:

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- 使用meta标签实现重定向 -->
    <meta http-equiv="refresh" content="5; url=http://localhost/day2/login.jsp" >
    <title>Insert title here</title>
    <script type="text/javascript">
        //这个js实现了页面显示秒数的改变,具体的跳转由meta标签实现
        var inner;
        window.onload = function(){
            inner = window.setInterval("showTime()", 1000);
        }
        function showTime(){
            var time = document.getElementById("time");
            var timeValue = time.innerHTML;
            if(timeValue>0){
                time.innerHTML -= 1;
            }else{
                window.clearInterval(inner);
            }
        }
    </script>
    </head>
    <body>
        <span id="time">5</span>秒后跳转到登录页面,如未跳转,请点击<a href="${pageContext.request.contextPath }/login.jsp">此处</a>
    </body>
    </html>

    3、

    【未完待续…】

  • 相关阅读:
    让网络编程更轻松和有趣 t-io
    设计一个百万级的消息推送系统
    前端安全系列之二:如何防止CSRF攻击
    Maven仓库下载jar包失败的处理方案
    SpringBoot2中配置文件的调整,升级SpringBoot2时候注意的坑
    Table折叠小技巧html-demo
    mysql如何分类统计数量
    前台登录和Token信息交互流程
    windows下安装mysql5.6
    【读书笔记】-- 你不知道的JavaScript
  • 原文地址:https://www.cnblogs.com/daimajun/p/6594190.html
Copyright © 2011-2022 走看看