Solved

onClick frame redirection

Posted on 2000-04-11
18
3,573 Views
Last Modified: 2008-03-17
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
Comment
Question by:Minuit
  • 10
  • 4
  • 3
  • +1
18 Comments
 

Author Comment

by:Minuit
ID: 2704884
Adjusted points from 5 to 10
0
 

Expert Comment

by:hakimus
ID: 2704937
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
 

Author Comment

by:Minuit
ID: 2704993
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
 

Expert Comment

by:hakimus
ID: 2705015
You can post the code?
Maybe can help us :)
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2705027
are you sure the page is called Main?

You might also want to try

onClick="parent.Main.location.replace('otherpage.ext')"
0
 

Author Comment

by:Minuit
ID: 2705035
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
 

Author Comment

by:Minuit
ID: 2705046
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
 

Expert Comment

by:hakimus
ID: 2705071
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
 
LVL 22

Expert Comment

by:CJ_S
ID: 2705074
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Minuit
ID: 2705448
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
 
LVL 22

Expert Comment

by:CJ_S
ID: 2706790
get rid of all those targets. And put in the HTML file itself the

<base target="Main">

in the header.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2706812
you also don;'t have a target in the Logo frame.
0
 

Author Comment

by:Minuit
ID: 2708132
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
 

Author Comment

by:Minuit
ID: 2709358
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
 

Accepted Solution

by:
james_butler<!-963D3690073723E190B030B2A23742DF--> earned 10 total points
ID: 2716639
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
 

Author Comment

by:Minuit
ID: 2716664
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
 

Author Comment

by:Minuit
ID: 2719159
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
 

Author Comment

by:Minuit
ID: 2719161
Code example showed that I was doing something wrong...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now