当用户点击此页面中的链接时,我想生成一个唯一的标题:
当用户点击其中一个链接时,标签标题应与csv对应。
以下是每种页面样式的HTML(标题标签所在的位置):
<title>Sortable & Responsive Table</title> //this is the current title that shows up on the tabs, but these must be unique, like Arc CSV or Coral CSV
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--[if !IE]><!-->
<style>
{
margin: 0;
padding: 0;
}
body {
font: 14px/1.4 Georgia, Serif;
}
#page-wrap {
margin: 50px;
}
p {
margin: 20px 0;
}
我有一个单独的JavaScript文件解析被点击的csv并在链接中加载相应的表 - 所以我认为生成一个唯一的标题就是这么简单(如果不是更简单):
Window.addEventListener(&#34; DOMContentLoaded&#34;,function()
{
var query = location.search;
query = query.slice(1);
var queryArray = query.split("&");
var file;
for (var i=0; i<queryArray.length; i++)
{
if (queryArray[i].slice(0, 4) === "csv=")
{
file = queryArray[i].slice(4);
}
}
var path = "../reservations/"+file+".csv";
d3.csv("../reservations/"+file+".csv", function(error, data) {
//generates unique table here
});
我对JavaScript / HTML不太熟悉,但我总是在学习。请告诉我。对不起,如果我错过了什么,请告诉我是否应提供其他代码/信息。我很感激!
答案 0 :(得分:0)
更改页面标题很简单:
// this changes the title
document.title = "New Title"
// create a higher order function
function setTitle(title) {
document.title = title
}
// and use it like this..
setTitle("New Title")
答案 1 :(得分:0)
也许是这样的:
<head>
<title></title>
</head>
<body>
<li><a onclick="change(theFile)"></a></li>
<script>
var theFile = "What you want";
function change(csv){
document.title = csv;
};
</script>
</body>
答案 2 :(得分:0)
在您的javascript函数中,更改以下行:
file{'Copy Team City agent tools':
ensure => directory,
path => $tc_tools_path,
source => 'puppet:///tools/TeamCityTools',
recurse => true,
}
到
var path = "../reservations/"+file+".csv";
d3.csv("../reservations/"+file+".csv", function(error, data) {
//generates unique table here
});