[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3616
  • Last Modified:

onClick frame redirection

I am working on an interface with four frames a logo, header, sidebar and the main (frames named appropriately) and on one of the pages shown in main has a submit button which I coded a redirection routine: onClick="javascript:parent.Main.location.href='Login2.htm'"

This will not redirect that frame for me.  I've tried in IE4/5.  I also tried making a separate function on a different frame page to do it as well as a few other redirections; it will redirect all frames except the Main.  The only I can redirect the Main frame using my function is with a hyperlink which calls it.  Any ideas on how to get the Main frame to redirect when it is the frame calling the function?
0
Minuit
Asked:
Minuit
  • 10
  • 4
  • 3
  • +1
1 Solution
 
MinuitAuthor Commented:
Adjusted points from 5 to 10
0
 
hakimusCommented:
Yoa can think in some like:
top.frames[1].location='menulats.html'

Top is the parent, if you have 4 frames "childrens", ypou can acces
by using: top.frames[i],
or if you have frames into one frames :
top.frame[i].frame[j]


You can see :
www.olympics.com
There have redirection of frames.
Too in:
http://developer.netscape.com/tech/
you can get the javscript documentation.


I hope this commnet will be useful for you.

Luis
0
 
MinuitAuthor Commented:
I tried that and it worked the same way; I can do subscripts 0,1,2 and those 3 frames will change, but the 4th frame (Main, subscript 3) will not change.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
hakimusCommented:
You can post the code?
Maybe can help us :)
0
 
CJ_SCommented:
are you sure the page is called Main?

You might also want to try

onClick="parent.Main.location.replace('otherpage.ext')"
0
 
MinuitAuthor Commented:
Here comes :)

On my "Logo" Frame...
function Switch() {
parent.Header.location.href="Header-Stu.htm"; } //Frame Changes
parent.SideBar.location.href="HeadBlank.htm"; //Frame changes
parent.Main.location.href="Login2.htm"; //Nothing happens
//top.frames[3].location.href="Login2.htm";
//this works the same as the previous line
}
</SCRIPT>

On my "Main" frame...
<input type="submit" value="Login" name="Submit" onClick="javascript:parent.Logo.Switch()">

This routine doesn't do any posting it's just for redirectional purposes right now.
0
 
MinuitAuthor Commented:
Sorry to make a book out of this but the replace command doesn't help either --> I've spent an hour trying to figure this one out; the only way I can get it to work is, on another page (different frame) I have:

<A HREF="javascript:parent.Logo.Switch()">TryMe</A>

and when I click "TryMe" the Main frame changes!
0
 
hakimusCommented:
Well, I dont understand....
top.frames[1].location="rul"
have worked for me always, changing diferents frames....
I dont understand exactly waht do you wan :(
0
 
CJ_SCommented:
function Switch() {
parent.Header.location.href="Header-Stu.htm"; } //Frame Changes *****
parent.SideBar.location.href="HeadBlank.htm"; //Frame changes
parent.Main.location.href="Login2.htm"; //Nothing happens
//top.frames[3].location.href="Login2.htm";
//this works the same as the previous line
}

****** you're closing the function before it reaches the other statements.

But I don't think there's anything wrong with ur function since it works the other way around. Can you show us the frame code?
0
 
MinuitAuthor Commented:
Here comes the frame code...
default.htm frameset:

<frameset rows="103,*" framespacing="0" border="0" frameborder="0">
  <frameset cols="*,88%">
    <frame name="Logo" scrolling="no" noresize src="Logo.htm" marginwidth="0" marginheight="0" scrolling="no" noresize>
    <frame name="Header" src="HeadBlank.htm" target="Main" marginwidth="0" marginheight="0" scrolling="no" noresize>
  </frameset>
  <frameset cols="98,*">
    <frame name="SideBar" target="Main" scrolling="no" noresize src="Side.htm">
    <frame name="Main" src="Main.htm" target="_self" scrolling="auto">
  </frameset>
  <noframes>
  <body>

  <p>This page uses frames, but your browser doesn't support them.</p>

  </body>
  </noframes>
</frameset>
0
 
CJ_SCommented:
get rid of all those targets. And put in the HTML file itself the

<base target="Main">

in the header.
0
 
CJ_SCommented:
you also don;'t have a target in the Logo frame.
0
 
MinuitAuthor Commented:
I fixed that stuff but still doesn't have an effect, after all what effect does changing the targets have if you are using javascript instead of hyperlinks to direct frames?
0
 
MinuitAuthor Commented:
After some testing; I have narrowed the problem down to the fact that I am trying to do with this with a form button.  I put a hyperlink on the Main frame, and gave it same code:
<a href="javascript:parent.Logo.Switch()">Test</a>

When clicking "Test" the page redirects... [so it must be to do with the button inside the form has to complete something before the page can change?]

Can anyone confirm this problem?
0
 
james_butler<!-963D3690073723E190B030B2A23742DF-->Commented:
I use a button to load multiple frames with no problems.  The button code is :

document.write('<form><input style="background-color:#66CCFF; cursor:hand" TYPE="button" VALUE="<< Back" onClick="goback()"></form>');

and the code for the function is :

function goback()
{      
      parent.frames["bleft"].location.href = "bottom_left.htm"
      parent.frames["tleft"].location.href = "top_left.htm"
      parent.frames["main"].location.href = "main.htm"
      parent.frames["mleft"].location.href = "middle_left.htm"
}

This works fine for all my pages.  The only difference I can see is I reference parent.frames["framename"].location
0
 
MinuitAuthor Commented:
James, is the form containing the form button one of "bleft","tleft","main", or "mleft"?  

i.e. did the frame with the form change?

One of the things I have to battle is --> changing the button from a SUBMIT button to a normal one.. will get back to it.
0
 
MinuitAuthor Commented:
I have changed the form button to a normal button instead of the "submit" type and it works beautifully.  Thanks for the help people although no one knew that was the exact problem.
0
 
MinuitAuthor Commented:
Code example showed that I was doing something wrong...
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 10
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now