CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 15th, 2002, 04:57 PM
coredumped coredumped is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2001
Posts: 149 coredumped User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 49 m 47 sec
Reputation Power: 7
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.

Reply With Quote
  #2  
Old October 16th, 2002, 02:21 AM
MJEggertson MJEggertson is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Seattle WA
Posts: 863 MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 sec
Reputation Power: 8
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > Meta tages & CSS using DOM functions?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway