日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

页面定时跳转(读秒)

發(fā)布時(shí)間:2024/4/13 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 页面定时跳转(读秒) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
頁面定時(shí)刷新(頁面讀秒操作)* 響應(yīng)的頭 refresh <meta http-equiv="refresh" content="5;url=/day10/response/login.html"> 發(fā)送http頭,控制瀏覽器定時(shí)刷新網(wǎng)頁(refresh) 多學(xué)一招:HTML<meta>標(biāo)簽來控制瀏覽器行為 package cn.learn.response;import java.io.IOException;import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;/*** 頁面的定時(shí)跳轉(zhuǎn)* @author Administrator**/ public class RefreshServlet extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {// 讀秒操作response.setContentType("text/html;charset=UTF-8");response.getWriter().write("<h1>頁面將在5秒后跳轉(zhuǎn)</h1>");// 通過refresh頭完成頁面刷新response.setHeader("refresh", "5;url=/day10/response/login.html");}public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {doGet(request, response);}} <!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"> <!-- 5秒后跳轉(zhuǎn) --> <meta http-equiv="refresh" content="5;url=/day10/response/login.html"> <title>頁面定時(shí)跳轉(zhuǎn)(讀秒)</title> </head> <body onload="run()"><h2>頁面將在<span id="spanId">5</span>秒后跳轉(zhuǎn)</h2></body><script type="text/javascript">/* 讀秒的操作頁面一加載,加載事件 onload執(zhí)行讀秒的操作,每隔一秒變一次。每隔一秒,js的定時(shí)器*/var x = 5;function run(){var span = document.getElementById("spanId");span.innerHTML = x;x--;window.setTimeout("run()", 1000);}</script></html>

?

總結(jié)

以上是生活随笔為你收集整理的页面定时跳转(读秒)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。