spacer

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

home / experts / javascript / column32


Loading An External HTML File

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Perhaps the most notable inconsistency between the browsers is by the way you can load an external HTML file to a dynamic HTML element. The challenge is pretty simple in Netscape Navigator. You just create a new layer and assign the external file name to its src property. The function fillFirstPage() accomplishes this task for the first page:

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

while the function fillSecondPage() accomplishes the same task for the second page:

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

The task is much more complicated in Internet Explorer. Internet Explorer suffers from a deficiency that you cannot assign a URL to a Dynamic HTML element's content. You can assign a string to the innerHTML or outerHTML properties of a Dynamic HTML. The solution is to load the external feed onto the page somehow, and then extract the messages from it. We use the IFRAME tag to load the page. Somewhere on your page put:

<IFRAME NAME="scroll" ID="scroll" STYLE="display:none"></IFRAME>

and then detect it from within the script by referring to the named IFRAME tag and assigning the external URL to it. This assignment is done inside startCanvs() function which is loaded first:

function startCanvas() {
  if (NS4) {fillCanvas();}
  else {document.all.tags("IFRAME").item("scroll").src = Gsrc;}
  setTimeout("window.onresize = redo", 1000);
}

The fillCanvs() function is called from the external HTML file in Internet Explorer, and from startCanvs() in Netscape Navigator:

function fillCanvas() {
  if (IE4) {arBody = document.frames("scroll").document.all.tags("BODY");};
  makeCanvas();
  setTimeout("showAndScroll()", Gdelay);
}

The first line extracts the BODY of the external file in Internet Explorer. Since the external file calls this function, any reference to document is a reference to the external file (jscolumns.html). The second line prepares the scrolling canvas, and the third line continues on with the generation of the two pages and their scrolling.

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


Created: December 21, 1998
Revised: May 16, 1999

URL: http://www.webreference.com/js/column32/load.html