Vertical Content Scroller script

Lets take a look now at the completed code for the scroller, with the script added in that scrolls the absolutely positioned DIV upwards before restarting when it has scrolled its entire height:

Dynamic PHP Picture Viewer
This script combines PHP with JavaScript to let you easily display all pictures within a directory without having to input their file names into the script! An external PHP file takes care of all the manual labour, by retrieving the list of images inside the directory and passing it onto the viewer script. Spiffy!

External JavaScript and PHP
External JavaScript can reference not just .js files, but PHP scripts as well. See how this is done, and the wonderful possibilities linking PHP to JavaScript bring.

Changing external style sheets using the DOM
Using the DOM, you can access and manipulate external style sheets on the page, from adding/deleting rules to modifying existing ones. This comprehensive tutorial shows you how.

Comprehensive guide to .htaccess
I've updated this tutorial with two new sections- blocking bad bots and users by referrer.

Applying border & opacity to images onMouseover in CSS
Learn how to spruce up images on your webpage with a border or opacity effect onMouseover, using CSS only.

Changing Select element content on the fly
This tutorial explains how to change a select element's content using JavaScript, from adding new options to modifying and deleting them. It also shows how to create a 2 level interdependent select list.

<style type="text/css">

position: relative;
width: 200px; /*marquee width */
height: 200px; /*marquee height */
background-color: white;
overflow: hidden;
border: 3px solid orange;
padding: 2px;
padding-left: 4px;


<script type="text/javascript">

* Cross browser Marquee II- Dynamic Drive (
* This notice MUST stay intact for legal use
* Visit for this script and 100s more.

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(>(actualheight*(-1)+8)) //if scroller hasn't reached the end of its height"px" //move scroller upwards
else //else, reset to original position"px"

function initializemarquee(){
actualheight=cross_marquee.offsetHeight //height of marquee content (much of which is hidden from view)
if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit"px""scroll"
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)


<div id="marqueecontainer" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">
<div id="vmarquee" style="position: absolute; width: 98%;">


<h4>Your scroller contents</h4>



Our content DIV (ID="vmarquee") is originally positioned at (0, 0) within the container DIV (ID="marqueecontainer"). I use a script to incrementally move the content DIV upwards until it's travelled its total height, calculated using:


Once it has, the DIV is reset back to (0, 0), and the whole process repeats. Refer to the comments inside script to follow the logic.

And there you have it, a cross browser content scroller that's easy to update and search engine friendly.