Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing to a document in an HTML <FRAMESET>

Status
Not open for further replies.

ChrisMacPherson

Programmer
Jul 3, 2000
157
GB
Here's the situation, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I have a frameset with three frames. One is a menu, one is the content, and the other is a header for the content.<br><br>I have added this line on to the end of my &lt;A HREF&gt; links in the menu: onClick=&quot;wrtHeader('header text')&quot;;&nbsp;&nbsp;&nbsp;<br><br>the function wrtHeader looks like this :<br>&nbsp;function wrtHeader(pageHeader)<br>&nbsp;&nbsp;&nbsp;{ <br>&nbsp;&nbsp;&nbsp;&nbsp;var header = &quot;&lt;HTML&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ &quot;&lt;HEAD&gt;etc...&lt;/HEAD&gt;&quot; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ &quot;&lt;BODY&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ &quot;&lt;p&gt;&quot; + pageHeader + &quot;&lt;/p&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ &quot;&lt;/BODY&gt;&lt;/HTML&gt;&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;top.headerFrame.document.write(header);<br>&nbsp;&nbsp;&nbsp;}<br><br>This funtion works fine if I click on a link, the header appears in the header frame, but when I click on a second link, nothing happens. I'm assuming that the next header is added to the bottom of the page in the header frame. So how do I replace the header that is already there?<br><br>Thanks for any help!<br><br>Chris Macp <br><A HREF=" TARGET="_new">
 
I think you need to open, write, then close the document. <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
yes, but maybe reloading it will be enough
 
Thanks, It works if I use the open() and close() method, BUT only in netscape(I use 4.6). It doesn't <br>work in Internet explorer (5). I have looked up the open(), close() statements in a book I have and <br>changed my function to this:<br><br>function wrtHeading(pageName)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var header = &quot;&lt;HTML&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ &quot; &lt;HEAD&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ &quot;&nbsp;&nbsp;&lt;LINK REL=stylesheet HREF=\&quot;macstyle.css\&quot; TYPE=\&quot;text/css\&quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ &quot; &lt;/HEAD&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ &quot; &lt;BODY BGCOLOR=\&quot;#000000\&quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ &quot;&nbsp;&nbsp;&lt;P CLASS=\&quot;header\&quot;&gt;&quot; + pageName + &quot;&lt;/P&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ &quot; &lt;/BODY&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ &quot;&lt;/HTML&gt;&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var target = open('heading.html','headframe');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;target.document.open();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;target.document.write(header);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;target.document.close();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>Do you know what the problem may be ? <br><br>I haven't tried reloading the page as Iza suggests because I dont know how!! Is there a reload() statement?
 
Only close the document then draw the html.<br><br>[frames.html]<br>&lt;html&gt;&lt;frameset cols=150,*&gt;<br>&lt;frame src=&quot;fr1.html&quot;&gt;<br>&lt;frame name=&quot;fr2&quot;&gt;<br>&lt;/frameset&gt;&lt;/html&gt;<br><br>[fr1.html]<br>&lt;html&gt;&lt;head&gt;&lt;script language=javascript&gt;<br>var f2=parent.fr2.document<br>function wrtHeader(v) {<br>&nbsp;f2.close();<br>&nbsp;f2.write('&lt;html&gt;&lt;body&gt;Header '+v+'&lt;/body&gt;&lt;/html&gt;')<br>}<br>&lt;/script&gt;&lt;/head&gt;&lt;body&gt;Menu:&lt;hr&gt;<br>&lt;li&gt;&lt;a href='javascript:wrtHeader(&quot;1&quot;)';&gt;Item 1&lt;/a&gt;&lt;br&gt;<br>&lt;li&gt;&lt;a href='javascript:wrtHeader(&quot;2&quot;)';&gt;Item 2&lt;/a&gt;<br>&lt;/body&gt;&lt;/html&gt;<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top