• 浏览器刷新页面问题


     

    【 reload 方法】该方法强迫浏览器刷新当前页面

    =================================================

    【一】要求刷新的窗口有一个名称,例如ABC。在要关闭的页面加入
        
        <body onunload="javascript:ABC.location.reload()">

    【二】如果要刷新的是将要关闭页面的父窗口,则可以在要关闭的页面加入

        <body onunload="javascript:window.opener.location.reload()">

    【三】刷新当前、父窗口、最顶端、指定时间刷新对象

    //页面加载时绑定按钮点击事件
    $(function(){
        $("#按钮id").click(function(){
            refresh();
        });
    });
    //点击按钮调用的方法
    function refresh(){
        window.location.reload();//刷新当前页面(强制刷新).
        //parent.location.reload()刷新父亲对象(用于框架)--需在iframe框架内使用
        //opener.location.reload()刷新父窗口对象(用于单开窗口)
        //top.location.reload()刷新最顶端对象(用于多开窗口)

        setTimeout('refresh()',1000); //指定1秒刷新一次
    }

    【四】如果想关闭窗口时刷新或想开窗时刷新

    <body onload="opener.location.reload()"> 开窗时刷新
    <body onUnload="opener.location.reload()"> 关闭时刷新
    <script language="javascript">
    window.opener.document.location.reload()
    </script>

    【五】自动刷新or跳转

    1.页面自动刷新:把如下代码加入<head>区域中

        <meta http-equiv="refresh" content="20">
        其中20指每隔20秒刷新一次页面.

    2.页面自动跳转:把如下代码加入<head>区域中

        <meta http-equiv="refresh" content="20;url=http://www.baidu.com">
        其中20指隔20秒后跳转到http://www.baidu.com页面

  • 相关阅读:
    Qt技巧、常用第三方库包含(qmake的.pro文件、CMakeLists.txt文件)
    STL资源
    debian 9 安装node angular
    debian 9 安装jenkins
    Consul 入门操作
    Docker 部署 postgresql 与 pgadmin4
    Docker File 与 Docker Compose
    Centos jdk
    Angular7 路由
    Centos Supervisor
  • 原文地址:https://www.cnblogs.com/webzwf/p/5714666.html
Copyright © 2020-2023  润新知