【发布时间】:2014-09-13 22:33:35
【问题描述】:
我有三个元变量:Concept、DocType 和 Path,我想将它们添加到我的 URL 中,以便在我的浏览器中找到类似于“http://www.mywebsite.com/page.html?concept=var1&doctype=var2&path=var3”的内容
现在我的页面上有以下代码,但我对 JS 很陌生,不确定这是否正确:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<meta name="concept" content="product" />
<meta name="docType" content="template" />
<meta name="Path" content="offer" />
<script>
function refresh() {
var concept = document.querySelector('meta[name="concept"]');
var doctype = document.querySelector('meta[name="docType"]');
var path = document.querySelector('meta[name="Path"]');
this.document.location.href = "?concept=" + concept.content + "&doctype=" + doctype.content + "&path=" + Path.content;
}
</script>
</head>
<body>
Line of text
<script>
if (location.search.indexOf("concept") !== -1) refresh();
</script>
</body>
</html>
这给了我以下错误,但我的网址没有更改:
回流:0.1ms 回流:0.11ms 回流:0.14ms 1406128139877 Services.HealthReport.HealthReporter WARN 未找到首选数据。
【问题讨论】:
标签: javascript meta-tags