470,835 Members | 1,912 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,835 developers. It's quick & easy.

how to force a child window to open in its frame set

how do I force a window, pened alone, to be displayed in its frame set?

tried this:

if (parent.location.href == self.location.href) {
window.location.href = '../';
}

the problem is that the original page is replaced by the main.htm page (the
default page for the 'main' frame)., because the open event of the menu page
calls for the main.htm to be loaded.
Is there a way that I could pass a page name as an argument to the index
page at all? Something like
window.location.href='index.html?Loc=IT_Study___In formation.htm';
TIA
BTW the web site is: http://uk.geocities.com/philippeoget/a2z/
Phil
Jul 23 '05 #1
3 2551
Is there a way that I could pass a page name as an argument to the index
page at all? Something like
window.location.href='index.html?Loc=IT_Study___In formation.htm';


First: This is one of the biggest reasons frames .... (are not so nice
to use).
But:
If you're stuck without serverside scripting like I was a while ago
trying to get stuff from the request, you could try this (I never put it
to the test for much other purposes than mine, so it may not work in all
situations! And watch out for possible nasty wrapping.):

Your passing the requested file on the URI is OK, then include code
below (pref. as external js) to all the pages that are loaded into the
frame that may have to be reloaded to the actually requested page.
Then in those pages do a test wether request.getParameter("Loc") equals
the filename of the loaded page. If not load the page from
request.getParameter("Loc").
This all ofcourse only when the page is not loaded as the toplevel-page.

I think it will do the trick...

<!-- //start copy code here
function parameterObject(){
qs = top.location.search;
if (qs.length > 1){
qs = unescape(qs.substr(1));
var parameters = qs.split("&");
for(var i=0;i<parameters.length;i++){
splitter = parameters[i].indexOf("=");
if ( (splitter>0) && (splitter<parameters[i].length-1) ){
prop = parameters[i].substr(0, splitter);
val = parameters[i].substr(splitter+1);
// check if property is already there
var testval = eval("this." + prop);
if (typeof testval != "undefined"){
eval("this." + prop + "='" + testval + "," + val + "'");
}else{
eval("this." + prop + "='" + val + "'");
}
}
}
}
}
function getRequestParameter(paramName){
//
return eval("this." + paramName);
}
parameterObject.prototype.getParameter = getRequestParameter;

// initialize var
var request = null;
// instantiate object
request = new parameterObject();
// end copy code here -->

Manno
Jul 23 '05 #2
In article <f6**************************@posting.google.com >,
ph**********@yahoo.com enlightened us with...
how do I force a window, pened alone, to be displayed in its frame set?
the problem is that the original page is replaced by the main.htm page (the
default page for the 'main' frame)., because the open event of the menu page
calls for the main.htm to be loaded.
Is there a way that I could pass a page name as an argument to the index
page at all?


Got server-side scripting?
It's a lot easier that way.

I have a dynamic frameset in JSP that does this exact thing.
--
--
~kaeli~
The definition of a will?... (It's a dead giveaway.)
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #3
manno wrote:
function parameterObject(){
This is used as a constructor, so

function ParameterObject()
{

is better (to distinguish it from methods).
qs = top.location.search;
You should care to check before you lookup:

<http://pointedears.de.vu/scripts/test/whatami>
if (qs.length > 1){
qs = unescape(qs.substr(1));
var parameters = qs.split("&");
I've learned that you should also split at ";":

var parameters = qs.split(/[&;]/);
for(var i=0;i<parameters.length;i++){
Looking up again and again is inefficient:

for(var i = 0, len = parameters.length, splitter, testval;
i < len;
i++)
{
splitter = parameters[i].indexOf("="); ^^^^^^^^

No reason to define undeclared globals. Declare your variables, see above.
if ( (splitter>0) && (splitter<parameters[i].length-1) ){
prop = parameters[i].substr(0, splitter); ^^^^ global
val = parameters[i].substr(splitter+1);
// check if property is already there
var testval = eval("this." + prop);
Yuck! There is exactly no reason for using evil eval() here:

<http://jibbering.com/faq/#FAQ4_40>
if (typeof testval != "undefined"){
Accessing

// corrected the previous statement;
// note that "testval" is declared (local)
// in the "for" statement
testval = this[prop];

already yields a warning, so you should write

if (typeof this[prop] != "undefined")
{
testval = this[prop];

eval("this." + prop + "='" + testval + "," + val + "'");
this[prop] = testval + "," val;
}else{
eval("this." + prop + "='" + val + "'");
this[prop] = val;
}
}
}
}
}
function getRequestParameter(paramName){
//
return eval("this." + paramName);
return this[paramName];
}
parameterObject.prototype.getParameter = getRequestParameter;

// initialize var
var request = null;
Nonsense.
// instantiate object
request = new parameterObject();


var request = new ParameterObject();
PointedEars
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Richard Bell | last post: by
2 posts views Thread by John Dalberg | last post: by
6 posts views Thread by SAL | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.