spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column33


The Scroller Code

Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

var IE4 = (document.all) ? true : false;
var NS4 = (document.layers) ? true : false;

var holdingImage = document.images["holdspace"];
var canvasLeft = docjslib_getImageXfromLeft(holdingImage);
var canvasTop = docjslib_getImageYfromTop(holdingImage);
var canvasWidth = docjslib_getImageWidth(holdingImage);
var canvasHeight = docjslib_getImageHeight(holdingImage);

var Gtimer = "";
var upperPage = "";
var lowerPage = "";
var arBody = new Array();

function onElementLoad(element, doThat, theseParameters) {
  if (NS4) eval(element).onLoad = eval(doThat)
  else eval(doThat + theseParameters);
}

function moveUp() {
    docjslib_moveVertically(firstPage, -Gincrement);
    docjslib_moveVertically(secondPage, -Gincrement);
    if (docjslib_getElementTop(lowerPage) <= 0) {
       docjslib_moveVertically(upperPage,
         docjslib_getElementHeight(upperPage) * 2);
  // (The above two lines should be joined as one line.
  // They have been split for formatting purposes.)
       rotateThePages();
     }
}

function rotateThePages() {
  if (upperPage == firstPage) {
    upperPage = secondPage;
    lowerPage = firstPage;
    return true;
  }
  upperPage = firstPage;
  lowerPage = secondPage;
  return true;
}


function scrollPages() {
  Gtimer = setInterval("moveUp()", Ginterval);
}

function stopScrolling() {
  clearInterval(Gtimer);
}

function launchScroller() {
  docjslib_setElementTop(secondPage,
    docjslib_getElementHeight(secondPage));
  // (The above two lines should be joined as one line.
  // They have been split for formatting purposes.)
  scrollPages();
}

function fillSecondPage() {
  secondPage = new Layer(canvasWidth - GleftPadding,canvas);
  secondPage.clip.width = canvasWidth - GleftPadding;
  secondPage.src = Gsrc;
}

function makeSecondPage() {
  if (NS4) fillSecondPage();
  docjslib_setElementLeft(secondPage, GleftPadding);
  secondPage.onmouseover = stopScrolling;
  secondPage.onmouseout = scrollPages;
  lowerPage = secondPage;
  docjslib_setElementVisibility(secondPage, true);
  onElementLoad(secondPage, "launchScroller", "()");
}

function fillFirstPage() {
  firstPage = new Layer(canvasWidth - GleftPadding, canvas);
  firstPage.clip.width = canvasWidth - GleftPadding;
  firstPage.src = Gsrc;
}

function showAndScroll() {
  if (NS4) fillFirstPage();
  docjslib_setElementLeft(firstPage, GleftPadding);
  docjslib_setElementTop(firstPage, 0);
  docjslib_setElementVisibility(firstPage, true);
  upperPage = firstPage;
  firstPage.onmouseover = stopScrolling;
  firstPage.onmouseout = scrollPages;
  onElementLoad(firstPage, "makeSecondPage", "()");
}

function fillAllPages() {
  var text = '<DIV ID="canvas" STYLE="position:absolute">';
  text += '<DIV ID="firstPage" STYLE="position:absolute">'
    + arBody[0].innerHTML + '</DIV>';
  // (The above two lines should be joined as one line.
  // They have been split for formatting purposes.)
  text += '<DIV ID="secondPage" STYLE="position:absolute">'
    + arBody[0].innerHTML + '</DIV>';
  // (The above two lines should be joined as one line.
  // They have been split for formatting purposes.)
  text += '</DIV>';
  document.body.insertAdjacentHTML("BeforeEnd", text);
}

function makeCanvas() {
  if (IE4) {fillAllPages();}
  else {canvas = new Layer(canvasWidth);}
  docjslib_createClipRegionAt00(canvas, canvasWidth, canvasHeight);
  docjslib_setElementWidth(canvas, canvasWidth);
  docjslib_setElementHeight(canvas, canvasHeight);
  docjslib_setElementLeft(canvas, canvasLeft);
  docjslib_setElementTop(canvas, canvasTop);
  docjslib_setElementBgColor(canvas, GcanvasColor);
  docjslib_setElementVisibility(canvas, true);
}

function fillCanvas() {
  if (IE4) {arBody =
    document.frames("scroll").document.all.tags("BODY");};
  // (The above two lines should be joined as one line.
  // They have been split for formatting purposes.)
  makeCanvas();
  setTimeout("showAndScroll()", Gdelay);
}

function startCanvas() {
  if (NS4) {fillCanvas();}
  else {document.all.tags("IFRAME").item("scroll").src = Gsrc;}
}

window.onload = startCanvas;

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Administering RBAC in PHP 5 CMS Framework · xref: Automatic Cross Referencing Script · Book Review: Content Rich
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags


Created: January 4, 1999
Revised: January 4, 1999

URL: http://www.webreference.com/js/column33/code1.html