HTML / JavaScript:如何停止选取框加载,并开始在鼠标悬停? [英] HTML/JavaScript: How to stop marquee onload, and start on mouseover?

查看:82
本文介绍了HTML / JavaScript:如何停止选取框加载,并开始在鼠标悬停?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下HTML代码段横向滚动文本:

 < marquee behavior =scroll direction =leftonmouseover =this.start(); onmouseout =this.stop();>继续......将鼠标悬停在我身上!< / marquee> 

我遇到的问题是,一旦您访问该页面,字幕开始自动滚动。我想要做的是冻结 marquee ,直到你使用鼠标悬停为止。

你可以用scrollAmount来修饰,而不是调用start()和stop(),并且最初将scrollamount设置为0。例如



< marquee behavior =scrolldirection =leftscrollamount =0onmouseover =this.scrollAmount = 6onmouseout < / marquee>



请参阅 =http://jsfiddle.net/svt9L/ =nofollow> http://jsfiddle.net/svt9L/

请注意,这是对你的问题的直接回答。不过,我完全赞同Jon P的回答。有比使用选取框元素更好的解决方案。


I'm using the following HTML piece of code to scroll text horizontally:

<marquee behavior="scroll" direction="left" onmouseover="this.start();" onmouseout="this.stop();">Go on... hover over me!</marquee>

The issue I have is that once you visit the page, the marquee starts scrolling automatically. What I want to do, is to freeze the marquee until you mouseover.

解决方案

You could tinker with scrollAmount instead of calling start() and stop(), and just set scrollamount to 0 initially. E.g.

<marquee behavior="scroll" direction="left" scrollamount="0" onmouseover="this.scrollAmount = 6" onmouseout="this.scrollAmount = 0">Go on... hover over me!</marquee>

See http://jsfiddle.net/svt9L/

Note that this is a direct answer to your question. However I fully endorse Jon P's answer. There are better solutions available than using the marquee element.

这篇关于HTML / JavaScript:如何停止选取框加载,并开始在鼠标悬停?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆