Floating Ad Script ?

Discussion in 'JavaScript' started by A.G, Dec 6, 2008.

  1. #1
    hey guys

    Do you know how can I make a floating ad that appears in the center of the page and every time the visitor scroll down the page , the ad moves too
     
    A.G, Dec 6, 2008 IP
  2. rene7705

    rene7705 Peon

    Messages:
    233
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    use a absolutely positioned div;

    <div id='ad' style='position:absolute; left : 200px; top : 200px; width : 300px; height : 300px;'>
    <!-- ad content here -->
    </div>

    and some javascript to auto-scroll it

    <script type='text/javascript'><!--
    window.onscroll = function () { //hope this works, havent tested it
    document.getElementById ('ad').style.top = (200 + document.body.scrollTop) + 'px';
    }
    --></script>
     
    rene7705, Dec 6, 2008 IP