Page 1 of 1
accessing frames and changing location.href
Posted: Sun Aug 28, 2005 9:58 am
by raghavan20
I have a page index.php
It has two frames, userMenus and mainFrame.
I have another page called homepage.php which has link to admin page.
the admin page actually consists of adminMenus.php and adminPage.php which is loaded on userMenus and mainFrame frames in index.php respectively.
If I now click on the homepage.php, then adminMenus.php should load in userMenus.php in index.php
and adminPage.php should load in mainFrame.php in index.php
I dont know wot to fill in these gaps.
Code: Select all
onclick=\"(????).mainFrame.location.href='adminPage.php'; (???).userMenus.location.href='userMenus.php'\"
Posted: Sun Aug 28, 2005 10:00 am
by feyd
suggestion: you should use a top level admin page that contains the frameset for the admin area. Common functionality and information can be stored in the top level admin page.
Posted: Sun Aug 28, 2005 10:45 am
by raghavan20
I dont know whether I understood you...
do you mean to create an adminMainPage which holds two frames and has adminMenus.php and adminPage.php in it.
I earlier thought of it. but thought why I need two top level pages for user and admin?? why dont we load pages accordingly in one top level page??
But is not possible to do wot I asked you in my earlier post??
Posted: Sun Aug 28, 2005 10:53 am
by feyd
it is, but the code needs to be inside the top level parent, not in a child frame.
Posted: Mon Aug 29, 2005 1:22 am
by n00b Saibot
simply replace your
???? with
top and thatsit...
feyd wrote:but the code needs to be inside the top level parent, not in a child frame
the above code with ???? replaced with top, will work from anywhere...
Posted: Mon Aug 29, 2005 1:37 am
by feyd
not necessarily. The object heirarchy may change, creating a script error if done from a child frame. The change should be performed by the top parent to be safe.
Posted: Mon Aug 29, 2005 1:44 am
by n00b Saibot
feyd wrote:not necessarily. The object heirarchy may change, creating a script error if done from a child frame. The change should be performed by the top parent to be safe.
I agree. But if the object heirarchy changes, would not there be error when accessing from parent frame too

Posted: Mon Aug 29, 2005 1:55 am
by feyd
not unless the entire document changes. Accessing siblings isn't a good idea, but accessing children and parens is fine.
Posted: Mon Aug 29, 2005 7:31 am
by raghavan20
I tried this but does not work instead it opens the index.php page with the userMenus.php on 'userMenus' frame and another page on 'mainFrame' frame.
Code: Select all
<a href = 'index.php' target='_self' onclick=\"top.mainFrame.location.href='adminPage.php'; top.userMenus.location.href='adminMenus.php'\">
I have made it work in another way
Code: Select all
//homePage.php
<a href = 'index.php?action=openPages&category=admin' >Admin Page</a>
Code: Select all
//index.php
<frameset cols="23%,80%" >
<?php
if (isset($_GET["action"])){
if($_GET["action"] == "openPages" && $_GET["category"] == "admin"){
?>
<frame src="adminMenus.php" name = "userMenus"/>
<frame src="adminPage.php" name = "mainFrame"/>
<?php
}
}else{
?>
<frame src="userMenus.php" name = "userMenus"/>
<frame src="listBlogs.php" name = "mainFrame"/>
<?php
}
?>
</frameset>
Posted: Mon Aug 29, 2005 7:43 am
by n00b Saibot
raghavan20 wrote:I tried this but does not work instead it opens the index.php page with the userMenus.php on 'userMenus' frame and another page on 'mainFrame' frame.
It wont, because of the way you have done it. This code
Code: Select all
<a href = 'index.php' target='_self' onclick="top.mainFrame.location.href='adminPage.php'; top.userMenus.location.href='adminMenus.php'">
loads index.php into _self which is mainFrame, hence the oddity. if you had chaged href="index.php" to href="#" and removed target bit, it would have worked perfectly.
Posted: Mon Aug 29, 2005 8:07 am
by raghavan20
It does not change even then
http://raghavan.allhyper.com/homePage.php#
username and password: visitor (each)
Posted: Mon Aug 29, 2005 8:27 am
by n00b Saibot
*sigh* this is so because there is no userMenus or mainFrame frames on this page. you need to have frames in place for this code to work. If you want to transit from a no=frame page to the one with frames, you are better off continuing with your temporary arrangement that you talked in few posts back.