自动刷新网页视图

时间:2019-03-09 11:33:41

标签: html google-chrome-app

我正在创建一个应自动刷新其窗口的webview Chrome应用。

我尝试使用html元刷新,但没有成功:

<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="refresh" content="5" >
    <link rel="stylesheet" href="../css/reset.css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<body>
    <!-- Most magic happens here -->
    <webview id="webview" src="URL" partition="persist:applicationize"></webview>
    <!-- Embed script to capture keystrokes -->
    <script src="../js/embed.js"></script>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

您可以使用javascript这样重新加载页面

location.reload();

要每5秒刷新一次,您可以执行以下操作

setInterval( () => {
  location.reload();
}, 5000)

该代码应位于扩展程序中,因为当您重新加载页面时,该页面的代码将停止执​​行。

OR

您可以在页面加载后触发setTimeout函数,这样将在5秒钟后执行刷新

setTimeout( () => {
  location.reload();
}, 5000)