<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1037327" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1037327</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/html-css-and-javascript/force-stylesheet-inframes-contents#comment-1214184</link>
    <description> &lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;I have the problem that my stylesheet for my XML document is ignored with either using [=&quot;Courier New&quot;]&amp;lt;?xml-stylesheet href=&quot;mystylesheet.css&quot; type=&quot;text/css&quot;?&amp;gt;[/] or by using an XHTML namespace with [=&quot;Courier New&quot;][/].&lt;/p&gt;
&lt;p&gt;Why is this? Thanks again.&lt;/p&gt;
 </description>
     <pubDate>Mon, 29 Jan 2007 10:07:17 +0000</pubDate>
 <dc:creator>Samji</dc:creator>
 <guid isPermaLink="false">comment 1214184 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/html-css-and-javascript/force-stylesheet-inframes-contents#comment-1214175</link>
    <description> &lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;&lt;strong&gt;Samji;214136 wrote:&lt;/strong&gt; Thanks. That change did indeed add the message text to the iframe. But I have the problem that it continually appends text for each message. How can I clear the frame before each new messages is appended?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;It was just a guide.  You&#039;ll have to use other DOM methods documented in my link above.  Look up [incode]replaceChild[/incode], [incode]removeChild[/incode] and [incode]hasChildNodes[/incode].  &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;&lt;strong&gt;Samji;214136 wrote:&lt;/strong&gt; Also can I apply a stylesheet by simply including [=&quot;Courier New&quot;][/] somewhere in the string to write out?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;That won&#039;t work, as the DOM methods modify the document tree, not the page&#039;s source text.  The easiest way would be to add that [incode]link[/incode] tag to the page&#039;s markup manually and leave it there.  There&#039;s no reason to alter the style information via scripting.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Mon, 29 Jan 2007 03:19:29 +0000</pubDate>
 <dc:creator>Abhishek Reddy</dc:creator>
 <guid isPermaLink="false">comment 1214175 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/html-css-and-javascript/force-stylesheet-inframes-contents#comment-1214136</link>
    <description> &lt;p&gt;Thanks. That change did indeed add the message text to the iframe. But I have the problem that it continually appends text for each message. How can I clear the frame before each new messages is appended?&lt;/p&gt;
&lt;p&gt;Also can I apply a stylesheet by simply including [=&quot;Courier New&quot;][/] somewhere in the string to write out?&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;function constructMsgBody() &lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // write out message contents to iframe on view dialog&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var message =&amp;nbsp; msgsfile.getElementsByTagName(&amp;quot;message&amp;quot;)[msg]&lt;br /&gt;.firstChild.nodeValue;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var writemsg = parent.frames[&amp;#039;msgframe&amp;#039;];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var writedoc = writemsg.document;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var writebody = writedoc.getElementsByTagName(&amp;quot;body&amp;quot;)[0];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; writebody.appendChild(writedoc.createTextNode(message));&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
 </description>
     <pubDate>Sun, 28 Jan 2007 14:53:33 +0000</pubDate>
 <dc:creator>Samji</dc:creator>
 <guid isPermaLink="false">comment 1214136 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/html-css-and-javascript/force-stylesheet-inframes-contents#comment-1214135</link>
    <description> &lt;p&gt;My apologies, the code I provided was untested and contained an error.  I referred to [incode]writemsg[/incode] instead of [incode]writedoc[/incode] in one place.  Here is the amended, tested (on Firefox 2) version:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;var writemsg = parent.frames[&amp;#039;msgframe&amp;#039;];&lt;br /&gt;&lt;br /&gt;var writedoc = writemsg.document;&lt;br /&gt;var writebody = writedoc.getElementsByTagName(&amp;quot;body&amp;quot;)[0];&lt;br /&gt;writebody.appendChild(writedoc.createTextNode(message));&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;A text node is what you should use here as [incode]message[/incode] is just a string, not a node itself.&lt;/p&gt;
&lt;p&gt;If [incode]message[/incode] was a subtree (fragment or node) taken from the original XML file, then you would simply append it without having to create a new node.&lt;/p&gt;
&lt;p&gt;But if you did want to create a new node -- say, to encapsulate even the text node above -- then you would use the [incode]createElement[/incode] method.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Sun, 28 Jan 2007 13:59:39 +0000</pubDate>
 <dc:creator>Abhishek Reddy</dc:creator>
 <guid isPermaLink="false">comment 1214135 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/html-css-and-javascript/force-stylesheet-inframes-contents#comment-1214133</link>
    <description> &lt;p&gt;Thanks for your help. I tried that code, but nothing appears in my iframe. Do you think I have to use a general node instead of a text node. What was the method for a general node.  [=&quot;Courier New&quot;]createNode[/]?&lt;/p&gt;
&lt;p&gt;Thanks again.&lt;/p&gt;
&lt;p&gt;Here&#039;s the code I have:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var message =&amp;nbsp;&amp;nbsp; msgsfile.getElementsByTagName(&amp;quot;message&amp;quot;)[msg]&lt;br /&gt;.firstChild.nodeValue;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert(message); //! bring up message in alert dialog !//&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var writemsg = parent.frames[&amp;#039;msgframe&amp;#039;];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var writedoc = writemsg.document;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var writebody = writemsg.getElementsByTagName(&amp;quot;body&amp;quot;)[0];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; writebody.appendChild(writedoc.createTextNode(message));&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;If I understand correctly, I am getting the contents of the message tag from my XML document and appending under the body element of the iframe.&lt;br /&gt;
Although the message appears fine in my alert, it is not being placed in the iframe.&lt;/p&gt;
 </description>
     <pubDate>Sun, 28 Jan 2007 11:40:13 +0000</pubDate>
 <dc:creator>Samji</dc:creator>
 <guid isPermaLink="false">comment 1214133 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/html-css-and-javascript/force-stylesheet-inframes-contents#comment-1214128</link>
    <description> &lt;p&gt;Rather than modifying the frame&#039;s contents with the [incode]document.write[/incode] function, use the &lt;a href=&quot;http://www.w3.org/TR/DOM-Level-2-Core/ecma-script-binding.html&quot; class=&quot;bb-url&quot;&gt;DOM methods&lt;/a&gt; -- essentially as you would with an XML file.&lt;/p&gt;
&lt;p&gt;Perhaps something like this (untested):&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;var writemsg = parent.frames[&amp;#039;msgframe&amp;#039;];&lt;br /&gt;var writedoc = writemsg.document;&lt;br /&gt;var writebody = writemsg.getElementsByTagName(&amp;quot;body&amp;quot;)[0];&lt;br /&gt;writebody.appendChild(writedoc.createTextNode(message));&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;Using the DOM functions ensures that the document tree remains sane, and so CSS can be applied by the browser.  As you&#039;re only modifying the sub-tree of the body node in this script, you can specify the stylesheet to apply in the page&#039;s code itself.&lt;/p&gt;
&lt;p&gt;However, note that you&#039;re only grabbing the nodeValue of the message, and in my example it is only appended as a text node.  If you&#039;re trying to append a general node from the XML file into the iframe&#039;s DOM tree, then you need slightly different code.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Sun, 28 Jan 2007 03:27:34 +0000</pubDate>
 <dc:creator>Abhishek Reddy</dc:creator>
 <guid isPermaLink="false">comment 1214128 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
