Novice needing expert advice

This is a discussion on "Novice needing expert advice" within the JavaScript Forum section. This forum, and the thread "Novice needing expert advice are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old May 29th, 2008, 13:03
New Member
Join Date: Oct 2007
Location: Manchester
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Novice needing expert advice

Hi I have compiled the below code, and it is working exactly how I want it to.

But if you click a link to another page on the news ticker, then click back the news ticker speed increases, if you do it again it further increases.

Why is this happening?

Thanks in advance,

Mike.

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Test</title>
        <script language="JavaScript" type="text/javascript">
            var delayb4scroll=2000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
            var marqueespeed=2 //Specify marquee scroll speed (larger is faster 1-10)
            var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?
            
            var copyspeed=marqueespeed
            var pausespeed=(pauseit==0)? copyspeed: 0
            var actualheight=''
            
            function scrollmarquee(){
            if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))
            cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
            else
            cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
            }
            
            function initializemarquee(){
            cross_marquee=document.getElementById("ticker_content")
            cross_marquee.style.top=0
            marqueeheight=document.getElementById("ticker_wrapper").offsetHeight
            actualheight=cross_marquee.offsetHeight
            if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
            cross_marquee.style.height=marqueeheight+"px"
            cross_marquee.style.overflow="scroll"
            return
            }
            setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll)
            }
            
            if (window.addEventListener)
            window.addEventListener("load", initializemarquee, false)
            else if (window.attachEvent)
            window.attachEvent("onload", initializemarquee)
            else if (document.getElementById)
            window.onload=initializemarquee
        </script>
        <style>
                #ticker_box{
                font-family : Arial, Helvetica, sans-serif;
                font-size : 12px;
                color : #115599;
                width : 450px;
                height : 190px;
                border : 1px solid #ebebeb;
                padding : 5px 15px 5px 15px;
            }
            #ticker_box a {
                text-decoration : none;
                color : #115599;
            }
            #ticker_wrapper{
                position : relative;
                height : 100%;
                overflow : hidden;
            }
            #ticker_content {
                position : absolute;
            }
            </style>
    </head>
    <body>
        <div id="ticker_box">
            <div id="ticker_wrapper" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">
                <div id="ticker_content">
                    <!--news story 1 start-->
                    <a href="http://www.anylink.com"><b>Title</b><br />
                    <br />
                    Content</a>
                    <!--news story 1 end-->
                </div>
            </div>
        </div>
    </body>
</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old May 29th, 2008, 13:16
CloudedVision's Avatar
Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 1,275
Blog Entries: 9
Thanks: 2
Thanked 40 Times in 40 Posts
Re: Novice needing expert advice

I don't see why it would be doing this. Could we get a link?
__________________
Web Design And Development: Other Road Design | Problems with IE6?: KApp | My Blog: Only Nerds Allowed | Learning PHP? Lessons
Last Blog Entry: Hilarious Rapper (Jul 29th, 2008)

Last edited by CloudedVision; May 29th, 2008 at 13:19.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old May 29th, 2008, 14:42
New Member
Join Date: Oct 2007
Location: Manchester
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Novice needing expert advice

Hi, Thanks for posting back.

I have now solved the problem, I just went through a massive process of elimination, i found out that if i changed the link of an article to another page and pressed back it was working the same, it turned out that the page I was linking used a
Code: Select all
window.addEventListener
function as i did on my page, for some reason this caused a conflict with my page when i returned to it, maybe you could explain why.
Many thanks,
Mike.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Novice..Help Building Discussion Forum AshbysAngel PHP Forum 1 Apr 18th, 2008 07:31
Novice to Asp.net sharad_kaku ASP.NET Forum 1 Aug 12th, 2006 17:32


All times are GMT. The time now is 05:02.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved