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

Discussion in 'Javascript' started by Phil, Apr 23, 2004.

  1. Phil

    Phil Guest

    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
    Phil, Apr 23, 2004
    #1
    1. Advertising

  2. Phil

    manno Guest


    > 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
    manno, Apr 23, 2004
    #2
    1. Advertising

  3. Phil

    kaeli Guest

    In article <>,
    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
    kaeli, Apr 23, 2004
    #3
  4. 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.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:

    <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
    Thomas 'PointedEars' Lahn, May 3, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bhchng
    Replies:
    0
    Views:
    642
    bhchng
    Jan 13, 2004
  2. thunk
    Replies:
    1
    Views:
    292
    thunk
    Mar 30, 2010
  3. thunk
    Replies:
    0
    Views:
    455
    thunk
    Apr 1, 2010
  4. Replies:
    1
    Views:
    239
  5. Spammay Blockay
    Replies:
    1
    Views:
    401
    Dietmar Meier
    Feb 4, 2005
Loading...

Share This Page