Link to home
Start Free TrialLog in
Avatar of superslamwich
superslamwichFlag for United States of America

asked on

sliding a message onmouseover

ok, its a pretty simple question.  In my navigation, I have a bunch of links to different places.  When the user puts their mouse over one of the links, i want a message telling about the page to scroll from left to right on the top of the navigation, and then stop when it hits the side:

  message<-------------------(scrolling)--------------------------message

I have tried using the html <marquee behavior='slide'> but it goes to slowly for my liking.  I tried to mimick the effect but faster using javascript, but it will not work either.  Here is the code:

<script language='javascript'>
<!--
     function slidemsg(message)  {
          document.getElementById('slider').innerHTML=message
          slideit()
     }
     function slideit()  {
          if(document.getElementById('slider').style.pixelLeft > 5)  {
               document.getElementById('slider').style.pixelLeft -= 10
               setTimeout('slideit()',1000)
          }
     }
//-->
</script>
<style>
<!--
#slider  {
     position:absolute;
     top:10;
     left:50;
}
-->
</style>
<body>
<div id='slider'></div>
<br>
<br>
<br><a href='main.html' onMouseOver='javascript:slidemsg("Main: The main page");'>Main</a><br>
<a href='sports.html' onMouseOver='javascript:slidemsg("Sports: Scores and stats for teams");'>Sports</a><br>
<a href='games.html' onMouseOver='javascript:slidemsg("Games: Fun games to pass the time with");'>Games</a>



There are other links as well, but these are just examples.

There is no error message, but the message does not slide across the screen.  
Any idea's?
Avatar of mikkolsoft
mikkolsoft
Flag of Hong Kong image

Is this what you want to achieve?
<script language='javascript'>
<!--
          var pixelLeft = 50;
    function slidemsg(message)  {
         document.getElementById('slider').innerHTML=message
         slideit()
    }
    function slideit()  {
         if(pixelLeft > 5)  {
                                   document.getElementById('slider').style.left = pixelLeft;
              pixelLeft -= 10;
              setTimeout('slideit()',1000)
         } else {
                          pixelLeft = 50;
                     }
    }
//-->
</script>

I am not too sure about the pixelLeft property but it's an IE-only attribute and you might want to use offsetLeft instead. If that's not the effect you want, let me know.

Mikkol
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of superslamwich

ASKER

that is the type of thing I want, the only problem is that with that script, if you move quickly from one to another, the words will speed up and go faster and faster and over and over.  Is there any way to get it to not do that but keep the effect?
sorry, i wrote the previous comment while COBOL was submitting his.  It's actually to mikkolsoft.

Anyway...

that scrolldelay attribute works great, it's exactly what I was looking for.  

Thanks a lot COBOLdinosaur!
superslamwich,
I just thought I'd mention that you can also use scrollamount=#, this sets how many pixels the text will move every time.
A pretty good description of the marquess properties here:

http://www.blooberry.com/indexdot/html/tagpages/m/marquee.htm

Glad we could help.  Thanks for the A. :^)

Cd&