JavaScript时钟现在显示在我的Chrome Extension中



在我的chrome扩展名(newtab(中,我的javaScript时钟不会显示出来,但是当我运行实际文件时,加载了加载。请帮助我尝试重新加载和重新包装,但仍无法使用。它为日期小时和第二个创建一个变量,然后将其添加在一起。编码:

<!DOCTYPE HTML>
<head>
<style>
.verticlecenter {
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
}
.button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 16px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
cursor: pointer;
border-radius: 25px;
}
.button2 {
background-color: white; 
color: black; 
border: 2px solid #008CBA;
}
.button2:hover {
background-color: #008CBA;
color: white;
}
input[type=text] {
 width: 250px;
 box-sizing: border-box;
 border: 2px solid #ccc;
 border-radius: 4px;
 font-size: 16px;
 background-color: white;
 padding: 12px 20px 12px 10px;
 -webkit-transition: width 0.4s ease-in-out;
  transition: width 0.4s ease-in-out;
text-align: center;
}
body {
background: #3A1C71;  /* fallback for old browsers */
background: -webkit-linear-gradient(to right, #FFAF7B, #D76D77, #3A1C71);      /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #FFAF7B, #D76D77, #3A1C71); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
</style>
<script>
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('txt').innerHTML =
h + ":" + m + ":" + s;
var t = setTimeout(startTime, 500);
}
function checkTime(i) {
if (i < 10) {i = "0" + i};  // add zero in front of numbers < 10
return i;
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
<div class="verticlecenter">
<center>
<form method="get" action="http://www.google.com/search">
<input type="text" name="q" size="25" maxlength="255" value=""     placeholder="Google Search" /><br>
<input class="button button2" type="submit" value="Search" /></td></tr>
</center>
</div>
</body>

清单文件:

{
"name": "tangoethan's NewTab",
"version": "1.0",
"manifest_version": 2,
"description": "tangoethan's newtab made by tangoethan",
"browser_action":{
    "default_icon": "icon.png"
},
"chrome_url_overrides": {
"newtab": "newtab.html"
  }
}

我找到了答案,在代码中有一个额外的结肠阻止chrome从扩展中读取它。

最新更新