October 15th, 2002, 04:57 PM
Meta tages & CSS using DOM functions?
I'm using DOM functions from one frame to create layers in another frame, which is empty, initially. The frameset is defined below.
My site initally defines a frameset that opens a page into a 'hidden' frame (CONTROLFRAME), that then calls functions
to render the site in the visible frame (DISPFRAME):
<FRAMESET ROWS="50%,*" SCROLLING=AUTO NORESIZE BORDER=0>
<FRAME SRC="domcontrol.html" NAME=CONTROLFRAME SCROLLING=NONE NORESIZE>
<FRAME SRC="about:blank" NAME=DISPFRAME SCROLLING=NONE NORESIZE>
I have been able to now successfully render layers, and other things into the blank 'DISPFRAME' using DOM functions, createElement, appendChild, etc.
Before I implemented the use of DOM functions, I explicitly called
document.write() from the CONTROLFRAME to write HTML into the DISPFRAME.
When I did this, I wrote ALL the HTML, including the
<HTML><HEAD><TITLE>....., etc. However, I also had two <META> tags and a <LINK> tag written as well, but since I've now abandoned that explicit writing, I don't have those tags defined in the document head anymore.
So my question is: Is there a way to create these tags using DOM functions as well?
I've tried the following code, but it didn't seem to work:
var _TEMP_OUTP = top.DISPFRAME.document.createElement("META");
... and ...
var _TEMP_OUTP01 = top.DISPFRAME.document.createElement("LINK");
How else might I be able to create these tags?
I've also tried top.DISPFRAME.document.getElementsByTagName("BODY").appendChild(_TEMP_OUTP01);
October 16th, 2002, 02:21 AM
I think createElement and appendChild is the only compliant way of doing it. The HTML DOM has no 'easy' way of adding elements. As for why your code doesn't work, I think only elements in the body tag can be added to affect the document after the initial load? I can't remember...I'll think about it some more, but now it's too late.
You could use other methods, like innerHTML to create elements, but then you run into browser issues. Methods like these are really only useful for specific environments where you know what the client is going to be.