Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
424 views
in Technique[技术] by (71.8m points)

javascript - 在HTA应用程序中使用具有滚动效果的HTML和Javascript显示当前日期和时间(Display the current date and time using HTML and Javascript with scrollable effects in hta application)

I have the below java-script to display the current date in the given format Mon Jun 2 17:54:28 UTC+0530 2014 in a hta(html application), now I want to make this appear in a way like Welcome the current date of my system: Mon Jun 2 17:54:28 UTC+0530 2014 and this text should be a having scrollable affects for eg: one moving from right to left.

(我用下面的Java脚本在hta(html应用程序)中以给定格式Mon Jun 2 17:54:28 UTC + 0530 2014显示当前日期,现在我想使它以类似于Welcome the current的方式显示我的系统的日期: 2014年6月2日星期一UTC + 0530 ,此文本应具有可滚动的效果,例如:一个从右向左移动。)

I tried to use the below tag to get a scrollable text but how can I call this java-script variable in the <marquee> tag so that I get the today's date and time also as a part of the scrollable affects but it is not working for my HTML page.

(我试图使用以下标签获取可滚动的文本,但是如何在<marquee>标签中调用此java-script变量,以便我也将今天的日期和时间作为可滚动影响的一部分,但它不起作用用于我的HTML页面。)

Kindly let me know how to rectify this issue

(请让我知道如何解决此问题)

HTML CODE:

(HTML代码:)

<marquee behavior="scroll" bgcolor="yellow" loop="-1" width="30%">
  <i><font color="blue"><strong>Welcome</strong> Today's date is : </font></i>
</marquee> 

JAVASCRIPT TO DISPLAY THE CURRENT DATE AND TIME:

(使用Java脚本显示当前日期和时间:)

 <script language="javascript">
 var today = new Date();
 document.write(today);
 </script>
  ask by Dojo_user translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Method 1:(方法1:)


With marquee tag.

(带marquee标记。)

HTML

(的HTML)

<marquee behavior="scroll" bgcolor="yellow" loop="-1" width="30%">
   <i>
      <font color="blue">
        Today's date is : 
        <strong>
         <span id="time"></span>
        </strong>           
      </font>
   </i>
</marquee> 

JS

(JS)

var today = new Date();
document.getElementById('time').innerHTML=today;

Fiddle demo here

(小提琴演示在这里)


Method 2:(方法2:)


Without marquee tag and with CSS .

(没有marquee标记,带有CSS 。)

HTML

(的HTML)

<p class="marquee">
    <span id="dtText"></span>
</p>

CSS

(的CSS)

.marquee {
   width: 350px;
   margin: 0 auto;
   background:yellow;
   white-space: nowrap;
   overflow: hidden;
   box-sizing: border-box;
   color:blue;
   font-size:18px;
}

.marquee span {
   display: inline-block;
   padding-left: 100%;
   text-indent: 0;
   animation: marquee 15s linear infinite;
}

.marquee span:hover {
    animation-play-state: paused
}

@keyframes marquee {
    0%   { transform: translate(0, 0); }
    100% { transform: translate(-100%, 0); }
}

JS

(JS)

var today = new Date();
document.getElementById('dtText').innerHTML=today;

Fiddle demo here

(小提琴演示在这里)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...