Java Script Newsticker Problem

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Java Script Newsticker Problem

    Hallo,

    ich habe einen newsticker wo die news von links reinlaufen und dann
    stehen bleiben und danach verschwinden.
    Ich habe es leider nicht hinbekommen das die news einfach druchlaufen und keine Pause machen.

    Suche dringend Hilfe.

    Habe hier den javascript teil gepostet, es gehört noch etwas css dazu

    Code:
    <script language="JavaScript" type="text/javascript">
    <!--
        var DOM = !!document.getElementById;
    
        if ( DOM )
        {
            window.onload = function()
            {
                window.newsticker = new Newsticker();
                newsticker.setStepWidth( 2 );
                newsticker.setSpeed( 45 );
                newsticker.setPauseAfterNews( 3000 );
    
    
                news = new News();
                news.setUrl( 'mitte.php?link=7' );
                news.setTarget( 'mainFrame' );
               news.setText( 'News test auf deutsch' );
               newsticker.addNews( news );            
               newsticker.start();
            }
        }
    
        function Newsticker()
        {
            this.m_News = new Array();
            this.m_Timer = null;
            this.m_StepWidth = 2;
            this.m_Speed = 10;
            this.m_PauseAfterNews = 1000;
    
            this.m_NewsContainer = null;
            this.m_NewsLink = null;
            this.m_NewsText = null;
    
            this.m_CurrentNews = null;
            this.m_CurrentNewsIndex = -1;
    
            this.m_Width = 0;
            this.m_CurrentLeft = 0;
            this.m_CurrentWidth = 0;
    
            this.setStepWidth = Newsticker_setStepWidth;
            this.getStepWidth = Newsticker_getStepWidth;
            this.setSpeed = Newsticker_setSpeed;
            this.getSpeed = Newsticker_getSpeed;
            this.setPauseAfterNews = Newsticker_setPauseAfterNews;
            this.getPauseAfterNews = Newsticker_getPauseAfterNews;
            this.addNews = Newsticker_addNews;
            this.start = Newsticker_start;
            this.next = Newsticker_next;
            this.step = Newsticker_step;
        }
    
    
        function Newsticker_setStepWidth( stepWidth )
        {
            this.m_StepWidth = stepWidth;
        }
    
    
        function Newsticker_getStepWidth()
        {
            return this.m_StepWidth;
        }
    
    
        function Newsticker_setSpeed( speed )
        {
            this.m_Speed = speed;
        }
    
    
        function Newsticker_getSpeed()
        {
            return this.m_Speed;
        }
    
    
        function Newsticker_setPauseAfterNews( pause )
        {
            this.m_PauseAfterNews = pause;
        }
    
    
        function Newsticker_getPauseAfterNews()
        {
            return this.m_PauseAfterNews;
        }
    
    
        function Newsticker_addNews( news )
        {
            this.m_News[this.m_News.length] = news;
        }
    
    
        function Newsticker_start()
        {
            this.next();
        }
    
    
        function Newsticker_next()
        {
            if ( this.m_Timer != null)
            {
                window.clearInterval( this.m_Timer );
            }
    
            this.m_CurrentNewsIndex++;
            if ( this.m_CurrentNewsIndex == this.m_News.length )
            {
                this.m_CurrentNewsIndex = 0;
            }
    
            this.m_CurrentNews = this.m_News[this.m_CurrentNewsIndex];
    
            var line = document.getElementById( 'Newsticker' );
    
            if ( this.m_NewsContainer == null )
            {
                this.m_Width = line.offsetWidth;
                this.m_NewsContainer = document.createElement( 'NOBR' );
                this.m_NewsContainer.className = 'Newsline';
    
                this.m_NewsContainer.style.position = 'absolute';
    
                this.m_NewsLink = document.createElement( 'A' );
                this.m_NewsLink.className = 'Newsline';
                this.m_NewsText = document.createTextNode( ' ' );
                this.m_NewsLink.appendChild( this.m_NewsText );
                this.m_NewsContainer.appendChild( this.m_NewsLink );
    
                document.body.appendChild( this.m_NewsContainer );
            }
    
            this.m_NewsLink.href = this.m_CurrentNews.getUrl();
            this.m_NewsLink.target = this.m_CurrentNews.getTarget();
            this.m_NewsText.data = this.m_CurrentNews.getText();
    
            this.m_CurrentLeft = getAbsoluteLeft( line ) + line.offsetWidth - 5;
            this.m_CurrentWidth = 0;
    
            this.m_NewsContainer.style.left = this.m_CurrentLeft + 'px';
            this.m_NewsContainer.style.top = getAbsoluteTop( line ) + 'px';
            this.m_NewsContainer.style.clip = 'rect(0px 0px 50px 0px)';
    
    this.m_Timer = window.setInterval( 'window.newsticker.step()', this.getSpeed() );
        }
    
    
        function Newsticker_step()
        {
            this.m_CurrentLeft -= this.getStepWidth();
            this.m_CurrentWidth += this.getStepWidth();
    
            this.m_NewsContainer.style.left = this.m_CurrentLeft + 'px';
    this.m_NewsContainer.style.clip = 'rect(0px ' + this.m_CurrentWidth + 'px 50px 0px)';
    
            if ( this.m_CurrentWidth >= this.m_Width )
            {
                window.clearInterval( this.m_Timer );
    this.m_Timer = window.setInterval( 'window.newsticker.next()', this.getPauseAfterNews() );
            }
        }
    
    
        function News()
        {
            this.m_Url = '';
            this.m_Target = '_blank';
            this.m_Text = '';
    
            this.setUrl = News_setUrl;
            this.getUrl = News_getUrl;
            this.setTarget = News_setTarget;
            this.getTarget = News_getTarget;
            this.setText = News_setText;
            this.getText = News_getText;
        }
    
        function News_setUrl( url )
        {
            this.m_Url = url;
        }
    
        function News_getUrl()
        {
            return this.m_Url;
        }
    
        function News_setTarget( target )
        {
            this.m_Target = target;
        }
    
        function News_getTarget()
        {
            return this.m_Target;
        }
    
        function News_setText( text )
        {
            this.m_Text = text;
        }
    
        function News_getText()
        {
            return this.m_Text;
        }
    
        function getAbsoluteLeft( element )
        {
            if ( element.offsetParent )
            {
             return element.offsetLeft + getAbsoluteLeft( element.offsetParent );
            }
            return element.offsetLeft;
        }
    
    
        function getAbsoluteTop( element )
        {
            if ( element.offsetParent )
            {
             return element.offsetTop + getAbsoluteTop( element.offsetParent );
            }
            return element.offsetTop;
        }
    //-->
    </script>
    <table><tr><td width=50 bgcolor='darkblue' align="center" height=14>
    <font size=1 face=Verdana color="white"><b>NEWS</b></font></td>
    <td width=450 bgcolor='#000070' align="center">
    <div id="Newsticker">&nbsp;&nbsp;</div></td>
    </tr></table>
    Zuletzt geändert von webINspirit; 28.01.2005, 14:27.

  • #2
    bitte lesen: http://www.php-resource.de/forum/sho...threadid=47906 und entsprechend handeln

    btw: und du meinst, dass irgendjemand den Sch**ß liest

    Kommentar


    • #3
      Wie soll ich den "scheiß" denn noch kürzen ohne den code zu zerstören??

      Kommentar


      • #4
        Naja, in dem du mal deien Ansätze lieferst, und nur entsprechende Stellen postest.

        Es ist doch so, dass du das Script irgendwo gezogen hast, und jetzt nen Sklaven suchst, der es dir nach deinen Wünschen anpasst. => Projekthilfe.

        Kommentar

        Lädt...
        X