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

P

Phil

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___Information.htm';
TIA
BTW the web site is: http://uk.geocities.com/philippeoget/a2z/
Phil
 
M

manno

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___Information.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.indexOf("=");
if ( (splitter>0) && (splitter<parameters.length-1) ){
prop = parameters.substr(0, splitter);
val = parameters.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
 
K

kaeli

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.


--
 
T

Thomas 'PointedEars' Lahn

manno said:
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:

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.indexOf("=");

^^^^^^^^

No reason to define undeclared globals. Declare your variables, see above.
if ( (splitter>0) && (splitter<parameters.length-1) ){
prop = parameters.substr(0, splitter);

^^^^ global
val = parameters.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:

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top