PythonistL wrote:
I am a newbie with Javascript. I have this simple script for scrolling
text
<HTML>
<HEAD>
<TITLE>Scrolling Message Script</TITLE>
<SCRIPT language="JavaScript"><!--
var msg = 'My scrolling text.. '
function scrollMsg(){
document.scrollDemo.textScroll.value = msg
msg = msg.substring(1,msg.length) + msg.substring(0,1)
setTimeout("scrollMsg()", 200)
}
//--></SCRIPT>
</HEAD>
<BODY bgcolor="white" onLoad="scrollMsg()">
<P>
<FORM name="scrollDemo">
<FONT face="Courier New,Courier" size=3><B>
<INPUT type="text" name="textScroll" size=30 value="Loading" ">
</B></FONT>
</FORM>
</BODY>
</HTML>
How must I change the script so that the text stops scrolling when I
put a mouse cursor over the text?
Don't use the language attribute on the script tag. It is deprecated.
Don't bother with the comment trick to hide the script from Netscape 1
or which every browser it was a long time ago.
It is probably a good idea to explicitly type the semi-colons at the
end of the JavaScript lines.
It might be better to use lower case tag and attribute names in case
you want to switch to XML/XHTML
Consider using a document type and validating your HTML
http://validator.w3.org/
I'm assuming your script example works. To stop the scrolling you can
keep and use a reference to the timeout. Note setTimeout can take a
function reference instead of a string if you want and it is more
efficient.
<script type="text/javascript">
var msg = 'My scrolling text..';
var myTimeout;
function scrollMsg() {
document.scrollDemo.textScroll.value = msg;
msg = msg.substring(1,msg.length) + msg.substring(0,1);
myTimeout = setTimeout(scrollMsg, 200);
}
</script>
<input type="text" onmouseover="if (myTimeout) {
clearTimeout(myTimeout; }">
And I would like to have a link to the scrolling text with <atag
e.g.
<a href="/TextDetail/">'My scrolling text.. </a>
Is it possible?
Maybe you really want
<a href="#textScroll">'My scrolling text.. </a>
I don't know about using the pound anchor with a name attribute. I use
the pound anchor with an element id this is because the name attributes
are not required to be unique but the id attributes are unique.
Peter