@WebJoelAug 10.2008 — #No need to post more than once. As a 'new member', posts are automatically witheld in a 'moderator's queue', for approval. Just a formality really. It's an anti-spam measure that greatly reduces SPAM/junk here. ? Once you attain 'trusted status' (undiscolosed number of posts), you become 'trusted' and your posts automatically appear on-forum when you "submit".
I don't know the answer to your question, -but someone else will. A Mod. whom 'oversees' this forum is on holiday for awhile... so, patience if no immediate answer. ? I'm sure replies will come.
@GueztAug 10.2008 — #Woops! I got mixed up as to who was posting what. I thought post #4 was posted by the OP, but now I realize it was posted by somebody else. So disregard what I said in my post #5.
@GueztAug 10.2008 — #Kasper Hviid... I'm not sure exactly what you're asking in post #8. Is it possible to write the entire page from scratch, from <HTML> to </HTML> by doing what exactly?
@Kasper_Hviid2authorAug 10.2008 — #Kasper Hviid... I'm not sure exactly what you're asking in post #8. Is it possible to write the entire page from scratch, from <HTML> to </HTML> by doing what exactly?[/QUOTE]
Sorry, I will try to make a bit more sense!
post #4 explained how to replace whatever is inside the BODY tag with something else.
What I want to do, is to replace whatever is inside the HTML tag with something else.
The reason I want to do this is that there are css stuff inside the HEAD tag which need to be replaced too.
@rnd_meAug 10.2008 — #Sorry, I will try to make a bit more sense!
post #4 explained how to replace whatever is inside the BODY tag with something else.
What I want to do, is to replace whatever is inside the HTML tag with something else.
The reason I want to do this is that there are css stuff inside the HEAD tag which need to be replaced too.[/QUOTE]
a lot of the head items need to be processed whilst the page is loading, or they won't take effect. you can probably use script to apply most of the settings, but it wont be as easy as simply replacing html's html with new html.
it would likely be more reliable to replace the body content, and then reload external stylesheets/scripts that are in the head.
@Angry_Black_ManAug 10.2008 — #What I want to do, is to replace whatever is inside the HTML tag with something else.
The reason I want to do this is that there are css stuff inside the HEAD tag which need to be replaced too.[/QUOTE]
it is very possible to look at any tag within an HTML page. simply use the "getElementsByTagName" method. this returns a collection (array) of elements that match your specified tag name. even if there is only one item that matches that name (the "head" tag, for instance), you must still use an index to refer to any specific element in that collection.
<style type="text/css"> body { background-color: #00ff00; } </style>
<style type="text/css"> div { text-decoration: underline; } </style>
<script type="text/javascript"> function info() { // getElementsByTagName returns an array // since there is only one head tag, // it would be represented by the first index of the array headerElement = document.getElementsByTagName("head")[0]
<i> </i>children = "the <HEAD> tag containsnthe following tags:nn"
<i> </i>for(x = 0; x < headerElement.children.length; x++) <i> </i> children += headerElement.children[x].nodeName + " (index " + x + ")n"
<i> </i>alert(children)
<i> </i>alert("removing the second style tag (index 2) whichncreates the underline within divs")
unfortunately, according to quirksmode, updating/adding a STYLE tag requires some pretty ghetto workarounds within IE. see the comment section in that quirksmode link for details.
@Kasper_Hviid2authorAug 10.2008 — #Thanks! I would never have understood this with any less thorough example. I had no idea that updating the header requiered any of this.
About adding style tags: I succeeded adding a new css file. It seems to work with both IE and others:
if (document.createStyleSheet) { // IE LIKES THIS ONE oStylesheet = document.createStyleSheet( "test2.css"); } else { // OPERA AND FIREFOX LIKES THIS ONE var fileref=document.createElement("link"); fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", "test2.css");