|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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): <HTML><HEAD><TITLE>DOM Testing</TITLE></HEAD> <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> </FRAMESET> </HTML> 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"); _TEMP_OUTP.setAttribute("http-equiv","Expires"); _TEMP_OUTP.setAttribute("content","-1"); top.DISPFRAME.document.head.appendChild(_TEMP_OUTP); ... and ... var _TEMP_OUTP01 = top.DISPFRAME.document.createElement("LINK"); _TEMP_OUTP01.setAttribute("REL","stylesheet"); _TEMP_OUTP01.setAttribute("TYPE","text/css"); _TEMP_OUTP01.setAttribute("HREF","style01.css"); top.DISPFRAME.document.head.appendChild(_TEMP_OUTP01); How else might I be able to create these tags? I've also tried top.DISPFRAME.document.getElementsByTagName("BODY")[0].appendChild(_TEMP_OUTP01); Thanks, - coredumped. |
|
#2
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > Meta tages & CSS using DOM functions? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|