gpt4 book ai didi

javascript - 在确认框上点击"is"后如何将元标记添加到文档中

转载 作者:太空宇宙 更新时间:2023-11-04 16:08:37 27 4
gpt4 key购买 nike

在确认框上单击"is"后,如何通过 js 添加元刷新标记?总体布局是...

<html lang="en">
<head>
<script type="text/javascript">
var metaRefreshConfirm = confirm("Do you want META Refresh?");
if (metaRefreshConfirm === true)
{
//code here for meta refresh
}
else if (metaRefreshConfirm === false)
{
alert("META Refresh not applied");
}
</script>
</head>
<body>
</body>
</html>

最佳答案

你可以这样做,创建节点并将其附加到head

<script type="text/javascript">
var metaRefreshConfirm = confirm("Do you want META Refresh?");
if (metaRefreshConfirm === true)
{
var meta = document.createElement('meta');
meta.httpEquiv = "refresh"
meta.content = "30";// secs
document.getElementsByTagName('head')[0].appendChild(meta);
}
else if (metaRefreshConfirm === false)
{
alert("META Refresh not applied");
}
</script>

关于javascript - 在确认框上点击"is"后如何将元标记添加到文档中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36167922/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com