小编Amr*_*esh的帖子

通过javascript动态更改元标记内容

我想使用 javascript 动态更改元标记内容,即刷新率和 url。使用按钮启用 javascript 功能。尝试了 3 种替代方法,但没有奏效。请帮忙。

谢谢,阿姆雷什

<!DOCTYPE html>
<html>
<head>
<meta HTTP-EQUIV="refresh" name="description" id="mymetatag"
      content="5;URL=http://localhost:6985/ChartJSDemo/Is_Mainpage.html">
<meta charset="ISO-8859-1">

<title>Processing Details</title>
<link rel="stylesheet" type="text/css" href="css/MF_job_failTable.css">
</head>

<body>

<button onclick="myFunction()">Click me</button>

<script>
function myFunction() {
    <!--document.querySelector('meta[name="description"]').setAttribute("content","5;URL=http://google.co.in");-->
    <!--document.getElementById("mymetatag").setAttribute("content", "5;URL=http://google.co.in");-->

  var m = document.createElement('meta'); 
  m.name = 'description'; 
  m.id = 'mymetatag';
  m.content = '5;URL=http://google.co.in'; 
  m.HTTP-EQUIV= 'refresh';
  document.head.appendChild(m);
}
</script>
Run Code Online (Sandbox Code Playgroud)

html javascript meta-tags

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

html ×1

javascript ×1

meta-tags ×1