-1
Ich bin ein riesiger nordischen Mythologie Buff und versuche, eine Ragnarok Countdown Chrome App zu machen. Der Code funktioniert gut auf einer Bearbeitungs-Website, und auch wenn ich es in diesen Beitrag einfüge, aber wenn ich versuche, es als eine App zu öffnen, macht die document.getElementById zur Anzeige der Uhr nichts, egal was ich mache, und ich habe alles gemacht. Hier ist der Code:document.getElementById funktioniert überhaupt nicht
<!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>
Was meinen Sie, wenn Sie ‚sagen, wenn ich versuche, es als App zu öffnen‚ – smarx
Oh, sorry, verpasste die Erwähnung von‘Chrome App. "Ich weiß nicht, wie diese funktionieren, daher bin ich mir nicht sicher, wie ich das Problem reproduzieren soll. Ich habe das" google-chrome-app "-Tag hinzugefügt, das hoffentlich die richtigen Experten anziehen wird. – smarx
Siehe https: //developer.chrome.com/extensions/contentSecurityPolicy Ich denke, Ihr '