我正在尝试将一个活动时钟放入文本正文中。我需要它流动,好像它只是文本的一部分,但仍然是本地设备的实时。在Adobe Muse中玩游戏我已经能够在文本中获得一个时钟,但它将自己分离到自己的行,而不是像段落一样流动。
以下是Muse制作的代码。我假设我需要对actAsInlineDiv normal_text
或actAsDiv excludeFromNormalFlow
或两者进行更改,但是如何更改?
<p id="u3202-10"><span class="Character-Style">You look at the clock on this device and it reads </span><span class="Character-Style"><span class="actAsInlineDiv normal_text" id="u13390"><!-- content --><span class="actAsDiv excludeFromNormalFlow" id="u13388"><!-- custom html --><html>
<head>
<script type="text/javascript">
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
// add a zero in front of numbers<10
m=checkTime(m);
document.getElementById('txt').innerHTML=h+":"+m;
t=setTimeout('startTime()',500);
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</html>
</span></span></span><span class="Character-Style">As a result you believe that this is the time. As it happens this is the time but unknown to you your device's clock has stopped functioning and is stuck. Does your true belief that this is the time count as knowledge?</span></p>
答案 0 :(得分:1)
我不了解缪斯,但如果你想要的只是当前时间的一个时钟与一些文字内联,你可以这样做:
window.onload = displayTime;
function displayTime() {
var element = document.getElementById("clock");
var now = new Date();
var options = {hour: '2-digit', minute:'2-digit'};
element.innerHTML = now.toLocaleTimeString(navigator.language, options);
setTimeout(displayTime, 1000);
}
&#13;
The current time is <span id="clock"></span> and it's inline with text.
&#13;
我添加了这两行来删除您在评论中提出的显示秒数。
var options = {hour: '2-digit', minute:'2-digit'};
element.innerHTML = now.toLocaleTimeString(navigator.language, options);