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!

Frames updating with javascript

Status
Not open for further replies.

hija

Programmer
Oct 30, 2002
16
AU
I am developing a web that is split into 2 frames in IE 5.0. The top frame holds a set of navigation buttons that will load the relevant page into the second frame.
The buttons are src jpg images and the code uses the onclick function to load the page.
The problem is after initial loading of the start page clicking on one of the buttons to move to a new page causes the button set in the top frame to dissappear, and is replaced by the browser looking into the current directory, (normal directory window).
If the 'back' button of the browser is clicked the top frame reappears and the page selected in the second frame remains available.

I have tried the 'location.reload' function, .self .window
.parent
to attempt to reload the top frame each time the onclick function is used, to no avail.

Can anyone tell me what I am doing wrong or what piece of code I need to solve this?
 
Name your frames something like menu and main
ie
<frameset rows=&quot;120,1*&quot;>
<frame src=&quot;menu.html&quot; name=&quot;menu&quot;>
<frame src=&quot;page1.html&quot; name=&quot;main&quot;>
</frameset>

on you navigation page use the following in your link tag

<A href=&quot;#&quot; onClick=&quot;parent.main.location.href='page2.html'&quot;>
<img src=yourimage.jpg>
</a>
regards
Ian Infinity exists! - I just haven't worked out a way to get there yet.

| |
 
ne4x4
Yep, the sample code you show is exactly as I have it currently structured.
The Menu frame sits along the top taking up 10% of the view area the remainder is a frame called page_viewer.
The switching between these pages works correctly, its just that in the process the menu frame dissappears. By using the back button I can get the menu frame to reappear so I can click to another page.

I tried <A href=&quot;#&quot; onClick &quot;parent.main.location='page2.html'&quot;; &quot;location.reload='menu.html'&quot;;><img src=&quot;myimage.jpg&quot;></A>

to refresh the menu frame put it does not work.
also tried &quot;.parent.menu.location='menu.html'&quot;
&quot;.self.location='menu.html'&quot;
&quot;.window.location='menu.html'&quot;

none seem to have any affect.
perhaps I have the syntax wrong, if so I would appreciate if someone could enlighten me.
hija
 
Hija

The original code I sent you works with ie6, mozilla 5 and opera7. It will load the second page into the &quot;main&quot; frame, leaving the navigation menu at the top.

Note you will need to change mainin
<A href=&quot;#&quot; onClick=&quot;parent.main.location.href='page2.html'&quot;>

to whatever you called your frame
Hope this helps
Infinity exists! - I just haven't worked out a way to get there yet.

| |
 
I think you're right most of the javascript worked ok. It would support frames using normal <a href=&quot;&quot; target=&quot;&quot;> but I seem to remember it was a bit quirky referencing frames directly with javascript.
Infinity exists! - I just haven't worked out a way to get there yet.

| |
 
Thanks guys, your points were most welcome and I have now solved the problem. It turned out to be (partially) a question of syntax. Below is the code line used.

<a href=&quot;#&quot; onClick=&quot;parent.Page_Viewer.location='SDMC_Home.html'; self.location='SDMC_menu.html'&quot; ><img src=&quot;.\SDMC_Assets\bHome.jpg&quot; height=37 alt&quot;&quot; border=&quot;0&quot;></a>


Each onClick event associated with the button most perform two operations. Load the required page in the page viewer frame and refresh the menu frame.
The 'self.location' points to the menu frame.
The syntax I got wrong was the double quote positioning.

onClick=&quot;parent.Page_Viewer.location='SDMC_Home.html'&quot;; &quot;self.location='SDMC_menu.html'&quot; ><img src=&quot;.\SDMC_Assets\bHome.jpg&quot; height=37 alt&quot;&quot; border=&quot;0&quot;></a>

As you can see I had separated each javascript statement with quotes preventing the second instruction from being acted on when the button was clicked.

Many thanks for your hints and tips.
hija
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top