How do you make sure a frameset is loaded? I'm trying to open a frameset in a new window which shows

Discussion in 'Javascript' started by ck388, Sep 24, 2003.

  1. ck388

    ck388 Guest

    I am trying to open a frameset in a new window......where the frame
    called "main" shows the file called customerGeneral.aspx. I can't get
    it to work though...i always get something like frames.main.location
    is null....seems like the frameset is not loaded before
    wnd.frames["main"].location.replace(URL) is called. If i add an
    alert("TEST") between the window open and the frame
    replacement....then it works. The alert("TEST") seems to ensure that
    the frameset is loaded so the wnd.frames["main"].location.replace(URL)
    executes without an error of null.

    I have included my code below.

    Any suggestions?

    function openInFrame(URL) {
    var wnd = window.open('frames/main.htm');
    // if i add this alert("TEST") it works.
    wnd.frames["main"].location.replace(URL);
    }

    e.Item.Cells[1].Text = "<a href=\"javascript:void(0)\"
    onclick=\"openInFrame('" + "customerGeneral.aspx?ID=" + ID + "')\">" +
    "This is a test" + "</a>";
     
    ck388, Sep 24, 2003
    #1
    1. Advertising

  2. ck388

    ck388 Guest

    (ck388) wrote in message news:<>...
    > I am trying to open a frameset in a new window......where the frame
    > called "main" shows the file called customerGeneral.aspx. I can't get
    > it to work though...i always get something like frames.main.location
    > is null....seems like the frameset is not loaded before
    > wnd.frames["main"].location.replace(URL) is called. If i add an
    > alert("TEST") between the window open and the frame
    > replacement....then it works. The alert("TEST") seems to ensure that
    > the frameset is loaded so the wnd.frames["main"].location.replace(URL)
    > executes without an error of null.
    >
    > I have included my code below.
    >
    > Any suggestions?
    >
    > function openInFrame(URL) {
    > var wnd = window.open('frames/main.htm');
    > // if i add this alert("TEST") it works.
    > wnd.frames["main"].location.replace(URL);
    > }
    >
    > e.Item.Cells[1].Text = "<a href=\"javascript:void(0)\"
    > onclick=\"openInFrame('" + "customerGeneral.aspx?ID=" + ID + "')\">" +
    > "This is a test" + "</a>";


    I figured out a work around. I used the ONLOAD method of the
    <frameset>. I did <frameset onload=
    window.frames["main"].location.replace("thePage.htm"). Make sure the
    frameset page is an ASPX page so you can replace the page with the
    correct page.

    Regards,

    Tim :)
     
    ck388, Sep 24, 2003
    #2
    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.

Share This Page