spacer

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

home / experts / javascript / column31


The Code

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

<HTML>
<HEAD>
<TITLE>A Scrolling JavaScript Canvas - www.docjavascript.com</TITLE>
<STYLE TYPE="text/css">
A.newslink {
text-decoration:none;
text-align:left;
color:blue;
font-size:14pt;
font-weight:bold;
font-style:normal;
font-family:serif;
line-height:14pt;
}
</STYLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
/* Copyright (c) 2000 internet.com Corp.  To receive the right
* to license this code to use on your site the original code must
* be copied from Webreference.com. License is granted if and only
* if this entire copyright notice is included, and you link from
* the page on which the code is used to Webreference at
* http://www.webreference.com/js/column31/ for the latest version.
*/
//
interval = 50;
  // The number of milliseconds between each vertical movement.
increment = 1; // The distance (in pixels) of each movement.
canvasColor = "#FFCC33";
  // background color of scroller, named or hex
//-->
</SCRIPT>
</HEAD>
<BODY>
<P>This is the beginning of the document.</P>
<P><IMG SRC="blank.gif"
        NAME="holdspace" ID="holdspace"
        WIDTH="350" HEIGHT="90"
        STYLE="visibility:hidden; position:relative;"></P>
<P>This is the end of the document.</P>
<IFRAME STYLE="display:none"></IFRAME>
<SCRIPT LANGUAGE="JavaScript1.2">
<!--


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

var Gtimer;

var upperPage;
var lowerPage;

var holdingImage = document.images["holdspace"];

var canvasLeft = holdingImage.offsetLeft;
var canvasTop = holdingImage.offsetTop;

var canvasWidth = holdingImage.width;
var canvasHeight = holdingImage.height;

var pageHeight = 0;

var arBody = new Array();

onload = startCanvas;

function showMessage() {
  upperPage = firstPage;
  lowerPage = secondPage;
  upperPage.style.pixelTop = 0;
  pageHeight = firstPage.clientHeight;
  secondPage.style.pixelTop = pageHeight;
  firstPage.onmouseover = stopScrolling;
  firstPage.onmouseout = scrollPages;
  secondPage.onmouseover = stopScrolling;
  secondPage.onmouseout = scrollPages;
}

function moveUp() {
  upperPage.style.pixelTop -= increment;
  lowerPage.style.pixelTop -= increment;
  if (lowerPage.style.pixelTop <= 0) rotateThePages();
}

function rotateThePages() {
  if (upperPage == firstPage) {
    upperPage = secondPage;
    lowerPage = firstPage;
  }
  else {
    upperPage = firstPage;
    lowerPage = secondPage;
  }
  lowerPage.style.pixelTop = pageHeight;
}

function makeCanvas() {
  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);
  with (canvas.style) {
	width = canvasWidth;
	height = canvasHeight;
	clip = "rect(0 " + canvasWidth + " " + canvasHeight + " 0)";
	backgroundColor = canvasColor;
  }
  canvas.style.pixelLeft = canvasLeft;
  canvas.style.pixelTop = canvasTop;
}

function startCanvas() {
  if (NS4) return;
  document.all.tags("IFRAME").item(0).src = 'jscolumns3ie.html';
}

function fillCanvas() {
  arBody = document.frames(0).document.all.tags("BODY");
  makeCanvas();
  showMessage();
  scrollPages();
}

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

function stopScrolling() {
  clearInterval(Gtimer);
}

//-->
</SCRIPT>
</BODY>
</HTML>

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

Whitepapers and eBooks

Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Microsoft PDF: Top 10 Reasons to Move to Server Virtualization with Hyper-V
Microsoft PDF: Six Reasons Why Microsoft's Hyper-V Will Overtake Vmware
Microsoft Step-by-Step Guide: Hyper-V and Failover Clustering
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Microsoft PDF: Top 11 Reasons to Upgrade to Windows Server 2008
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
  PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
HP eBook: Guide to Storage Networking
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Fixing MySQL Replication · Firewall Guide: First Steps to Securing the Enterprise · VoxOx Tames the Tumultuous Communications Tangle


Created: November 23, 1998
Revised: November 23, 1998

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