Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 有没有办法阻止元刷新自动刷新页面?_Javascript_Html_Userscripts - Fatal编程技术网

Javascript 有没有办法阻止元刷新自动刷新页面?

Javascript 有没有办法阻止元刷新自动刷新页面?,javascript,html,userscripts,Javascript,Html,Userscripts,我进入一个网页,该网页下面有代码,一分钟后会将我重定向到另一个网页 <meta http-equiv="refresh" content="60; URL='LinkToAnotherWebsite.com'"> 您始终可以使用javascirpt覆盖meta标记的值 Array .from(document.getElementsByTagName("meta")) .filter(elem =>

我进入一个网页,该网页下面有代码,一分钟后会将我重定向到另一个网页

<meta http-equiv="refresh" content="60; URL='LinkToAnotherWebsite.com'">

您始终可以使用javascirpt覆盖meta标记的值

Array
    .from(document.getElementsByTagName("meta"))
    .filter(elem => elem.getAttributeNames().includes("http-equiv") && elem.getAttribute("http-equiv") === "refresh")[0] // it might return undefined so put it in try catch
    .setAttribute("content", "VALUE YOU WANT TO SET");

如果您可以为站点编写用户脚本,则可以尝试删除
标记

document.querySelector(“meta[http equal='refresh']”?.remove()

从文档中删除
标记?@Phil yeah这是一个解决方案,或者如果我是管理员的话。我认为应该可以使用用户脚本,但我不知道如何使用,这就是我为什么要问的原因,但我如何才能将其自动嵌入到页面上?我可以使用用户脚本来执行此操作吗?如果您控制该网站,则可以直接从代码中删除它;如果您对该网站没有控制权,则可以在浏览器中配置刷新设置以忽略刷新,否则还可以使用扩展名或创建扩展名
Array
    .from(document.getElementsByTagName("meta"))
    .filter(elem => elem.getAttributeNames().includes("http-equiv") && elem.getAttribute("http-equiv") === "refresh")[0] // it might return undefined so put it in try catch
    .setAttribute("content", "VALUE YOU WANT TO SET");