【问题标题】:Simulate chat messages on my website在我的网站上模拟聊天消息
【发布时间】:2014-04-05 11:11:33
【问题描述】:

我怎样才能逐行显示文本,并进行几秒钟的时移。
用户应该无法回答。
我想模拟聊天消息。

【问题讨论】:

  • 是的。如果您向我们展示您到目前为止所做的代码,也许有人可以提供帮助。
  • 也许我没有添加代码,因为我不知道怎么做,这将解释我为什么问这个问题。
  • 这里有一个页面,它提供了有关如何提问的建议 - stackoverflow.com/help/how-to-ask。您必须有一些代码要共享,以便有人可以帮助您。例如,您已经有一个页面,您可以给我们页面的一部分,您希望伪聊天框是/弹出的吗?是否应该有文本供用户查看?文字是什么?
  • 这将是一个空白的 404 站点,应该没有任何内容,除了一些像对话这样的文本。我只想知道如何在另一行 tet 之后显示一行文本。没有像弹出窗口之类的特殊东西。这就是为什么我没有写任何关于它的东西。

标签: javascript html css ajax web


【解决方案1】:

FIDDLE 将帮助您入门。

  1. 随机短语数组

  2. 一个随机读取它们并将它们放置在一个 div 中的定时器函数。

JS

var randomphrases = ['We the people','in order to form','a more perfect union','establish justice','insure domestic tranquility','provide for the common defence, promote the general welfare','and secure the blessings of liberty','to ourselves','and our posterity','do ordain and establish this constitution','of the United States of America'];

var c = 0;
var t;
var timer_is_on = 0;

timedCount();

function timedCount()
{
 t = setTimeout( function(){ timedCount() }, 1500 );
 random = Math.floor(Math.random() * (11 - 0 + 1)) + 0;
 $('.putmehere').html( randomphrases[random]);

}

【讨论】:

  • 感谢您的帮助,我最终得到了这个 FIDDLE,它完全符合我的要求。
猜你喜欢
  • 2015-03-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-26
  • 1970-01-01
  • 2015-09-09
  • 1970-01-01
相关资源
最近更新 更多