PDA

View Full Version : Context dependent file display



monkeybiznus
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">
<br>
<div id=box>
</div>

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

HOME.JS FILE:
<div id=intron1>
</div>
All of my content
<div id=intron2>
</div>

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

INTRON2.js:
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)