-1
工作我是一個巨大的北歐神話的buff,我試圖做一個仙境傳說倒計時Chrome應用。該代碼工作正常上一個編輯的網站,即使我把它放在這個職位,但是當我嘗試打開它作爲一個應用程序時,的document.getElementById顯示時鐘沒有做任何事情,無論我做什麼,我做了所有事情。下面是代碼:的document.getElementById完全不
<!DOCTYPE HTML>
<html>
<head>
<style>
p {
text-align: center;
font-size: 60px;
}
body {
color:white;
background-color:gray;
</style>
</head>
<body>
<p id="demo"></p>
<script>
window.onload = (function() {// Set the date we're counting down to
var countDownDate = new Date("Jan 1, 2099 12:00:00").getTime();
// Update the count down every 1 second
var x = setInterval(function() {
// Get todays date and time
var now = new Date().getTime();
// Find the distance between now an the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var years = Math.floor(distance/(1000 * 60 * 60 * 24 * 365));
var days = Math.floor((distance % (1000 * 60 * 60 * 24 * 365))/(1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24))/(1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60))/(1000 * 60));
var seconds = Math.floor((distance % (1000 * 60))/1000);
// Output the result in an element with id="demo"
document.getElementById("demo").innerHTML = years + "y" + days + "d " + hours + "h "
+ minutes + "m " + seconds + "s ";
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "Prepare for Ragnarok";
}
}, 1000);});
</script>
</body>
</html>
你是什麼意思時,你說「當我嘗試打開它作爲一個應用程序‘ – smarx
哦,對不起,錯過了提’Chrome應用。 「我不熟悉如何將這些工作,所以我不知道如何嘗試重現該問題,我已經添加了'谷歌鉻app'標籤,這將有望吸引到合適的專家 – smarx
見HTTPS。: //developer.chrome.com/extensions/contentSecurityPolicy。我想你''