• JSP实现页面自动跳转


    一些页面自动跳转的实现

    功能:

    8

    秒后,自动跳转到同目录下的

    return.html

    文件

    1

    html

    的实现

    <head>

    <meta http-equiv="refresh" content="5;url=return.html">

    </head>

    2

    javascript

    的实现

    <script language="javascript" type="text/javascript">

    setTimeout("javascript:location.href='return.html'", 8000);

    </script>

    3

    )结合了倒数的

    javascript

    实现(

    IE

    <span id="totalSecond">8</span>

    <script language="javascript" type="text/javascript">

    var second = totalSecond.innerText;

    setInterval("redirect()", 1000);

    function redirect(){

    totalSecond.innerText=--second;

    if(second<0) location.href='return.html';

    }

    </script>

    3'

    )结合了倒数的

    javascript

    实现(

    firefox

    <script language="javascript" type="text/javascript">

    var second = document.getElementById('totalSecond').textContent;

    setInterval("redirect()", 1000);

    function redirect()

    {

    document.getElementById('totalSecond').textContent = --second;

    if (second < 0) location.href = 'return.html';

    }

    </script>

    4

    )解决

    Firefox

    不支持

    innerText

    的问题

    <span id="totalSecond">8</span>

    <script language="javascript" type="text/javascript">

    if(navigator.appName.indexOf("Explorer") > -1){

    document.getElementById('totalSecond').innerText = "my text innerText";

    } else{

    document.getElementById('totalSecond').textContent = "my text textContent";

    }

    </script>

    5

    )整合

    3

    )和

    3'

    <span id="totalSecond">8</span>

    <script language="javascript" type="text/javascript">

    var second = document.getElementById('totalSecond').textContent;

    if (navigator.appName.indexOf("Explorer") > -1)

    {

    second = document.getElementById('totalSecond').innerText;

    } else

    {

    second = document.getElementById('totalSecond').textContent;

    }

    setInterval("redirect()", 1000);

    function redirect()

    {

    if (second < 0)

    {

    location.href = 'return.html';

    } else

    {

    if (navigator.appName.indexOf("Explorer") > -1)

    {

    document.getElementById('totalSecond').innerText = second--;

    } else

    {

    document.getElementById('totalSecond').textContent = second--;

    }

    }

    }

    </script>

    不在

    jsp

    页面中嵌套

    java

    代码片段

    <html>

    <head>

    <script type="text/javascript">

    function delayedRedirect(){

    window.location = http://localhost:8080/redirect/login.jsp;

    }

    </script>

    </head>

    <body onLoad="setTimeout('delayedRedirect()',3000)">

    <h2>3

    秒钟后将自动跳转到登陆页面

     </h2>

    </body>

    </html>

  • 相关阅读:
    redis 3 通用指令
    查看表索引
    truncate的用法
    Java(0)_ 安装jdk
    Java(9)_ 集合(3)
    Java(10)_File&递归&字节流
    Java(8)_ 集合(2)
    Appium+python的单元测试框架unittest(3)——discover
    Appium+python的单元测试框架unittest(2)——fixtures
    爬楼梯
  • 原文地址:https://www.cnblogs.com/hualidezhuanshen/p/3266256.html
Copyright © 2020-2023  润新知