View Full Version : Context dependent file display

05-01-2006, 11:28 AM
I am trying to reference a file (it's a .js file, HOME.js, but it only contains HTML tags) using ajax on two seperate pages. On one page (page A), I want the code to become part of the page and display as HTML, and on the other page (page B), I want the code to be included within a textarea box.

I have encountered some difficulty in setting this up; So far I the best I could do is the rather crude method of including in the HOME.js file empty div tags at the begining and end of the file and code on page A that will include a textarea tag in these div tags when the HOME.js file is loaded, as follows:

PAGE A.html:
<input type="button" onClick="javascript:ajaxpage('HOME.js', 'box');loadobjs('INTRON1.js', 'INTRON2.js')" value="Load">
<div id=box>

PAGE B.html:
<body bgcolor="#ffffff" vlink="#0000ff" onLoad="javascript:ajaxpage('HOME.js', 'page');" >
<div id=page>

<div id=intron1>
All of my content
<div id=intron2>

document.getElementById('Intron1').innerHTML = '<textarea>'

document.getElementById('Intron2').innerHTML = '<\/textarea>'

This gets me close, as on page A a textarea box will appear on the page, but the rest of the HOME.js file is contained outside the box. Apparently a closing div tag ends a textarea tag.

I am trying this because my server doesn't support any SSI or CGI.
Sorry if my post is redudant, or in the incorrect forum
Thanks (btw, if anybody suspected from my naming of the empty div tag, I am a molecular biology major)