正如标题所述,im需要在html框中暂停滚动文本。
它被用在相机旁边的一台小型笔记本电脑上,作为滚动脚本让我阅读--基本上,滚动器工作得很好,而且非常简单,但很明显,如果我需要停下来,如果我开始在脚本中间或任何原因上闲谈其他东西,我就不会停在笔记本电脑上。
我最初的想法是买一个小型的蓝牙键盘(因为那里很便宜),把它放在我站着的地板上,这也会让我的手不受干扰。然后,我可以暂停和播放滚轮没有任何问题。
所以我想问题是,我可以用带有javascript的键盘空格来暂停它吗?如果是的话,如何暂停呢?
这是我的主题曲(这是对它的翻拍,因为原版在我的笔记本上):
<body style="styles-here">
<marquee style="styles-here" behavior="scroll">
TEXT TO SCROLL
</marquee>任何帮助都是非常感谢的!
发布于 2014-11-28 04:05:54
您可以使用stop和start方法
var state = 'play';
function toggleMarquee() {
var marquee = document.getElementById("marq");
if (state === 'play') {
marquee.stop();
state = 'stop';
} else {
marquee.start();
state = 'play';
}
}<marquee id="marq">This text will scroll from right to left</marquee>
<input type="button" onclick="toggleMarquee();" value="Toggle" />
编辑
若要向按钮添加键盘快捷方式,请参见:How to create a keyboard shortcut for an input button
发布于 2014-11-28 04:45:35
<marquee onmouseover="this.stop();" onmouseout="this.start();">my text here</marquee>这应能完成所要求的工作。
谢谢帕夫
https://stackoverflow.com/questions/27181648
复制相似问题