Results 1 to 3 of 3

Thread: Modification of "Cross browser Marquee script" to dynamic width

  1. #1
    Join Date
    Sep 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Modification of "Cross browser Marquee script" to dynamic width

    I was made simple changes to "Cross browser Marquee script", but please, tell me, that's a good solution? And one trouble - if i resize a window after loading script does not recalculating results, please if you can, help me use OnResize event, i don't know JavaScript

    function getClientWidth()
    {
    return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
    }
    var MyWidth = getClientWidth()



    //Specify the marquee's width (in pixels)
    var marqueewidth= MyWidth

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,957
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    Warning: Please include a link to the DD script in question in your post. See this thread for the proper posting format when asking a question.


    Please post a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Sep 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default New script!

    One kind men write script with my needs, but have two not solved troubles...
    First - i want to see text in loop without vaiting for going out text before seeng repeat, i want to see "powerfull marquee script | This is the most " and the second - if i have long string i see horizontal scroller in browser But script are working:
    Code:
    <script>
    // настройка скорости
    delay = 30;
    step = 2;
    
    is_start = true;
    fullwidth = 0;
    cpos = 0;
    scrollw = 0;
    
    function start_scroll()
    {
      var scrolltext = document.getElementById('scrolltext');
      var scroll = document.getElementById('scroll');
    
      fullwidth = scrolltext.offsetWidth;
      scrolltext.style.left = scroll.offsetWidth;
      scrollw = scroll.offsetWidth;
      scrolltext.style.position = 'relative';
      
      myinterval = setInterval(do_scroll, delay);
    }
    
    function do_scroll()
    {
      var scroll = document.getElementById('scroll');
      var scrolltext = document.getElementById('scrolltext');
      
      if (is_start)
      {
        cpos = scroll.offsetWidth;
        scrolltext.style.left = cpos;
        is_start = false;
      }
      else
      {
        cpos -= step;
        scrolltext.style.left = cpos;
        if (cpos < -fullwidth) { is_start = true; }
      }
    }
    
    function stop_scroll()
    {
      clearInterval(myinterval);
    }
    
    function continue_scroll()
    {
      myinterval = setInterval(do_scroll, delay);
    }
    
    function do_resize()
    {
      var scroll = document.getElementById('scroll');
      newscrollw = scroll.offsetWidth;
      
      if (cpos >= 0) { absstp = scrollw - cpos; }
      else { absstp = scrollw + Math.abs(cpos); }
    
      oldprc = absstp / (scrollw + fullwidth);
      newlen = newscrollw + fullwidth;
      newabsstp = newlen * oldprc;
    
      if (newabsstp <= newscrollw) { cpos = newscrollw - newabsstp; }
      else { cpos = -(newabsstp - newscrollw); }
    
      scrollw = newscrollw;
    }
    </script>
    
    <style>
    #scroll {width: 100%;
             background-color: f0f0f0;
             white-space: nowrap;
             overflow: hidden;
             position: relative}
    #scrolltext {position: absolute}
    </style>
    
    <body onload='start_scroll()' onresize='do_resize()'>
    
      <div style='width:100%'>
    
          <div id='scroll' onmouseover='stop_scroll()'
          onmouseout='continue_scroll()'>
           <div id='scrolltext'>
            Здесь скроллируемый текст,
            его скорость настраивается,
            в нем есть <a href=''>ссылка</a>,
            при наведении мыши он останавливается
           </div>
          </div>
    
      </div>
    
    </body>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •