writing to a frame - moz

Discussion in 'Javascript' started by mlybarger@gmail.com, May 25, 2005.

  1. Guest

    i have a popup window that's built from javascript with something like:

    source += "<html>";
    source += " <head>";
    source += " </head>";
    source += " <frameset rows='100,*'>";
    source += " <frame id='controls' name='controls' />";
    source += " <frame id='data' name='data' />";
    source += " </frameset>";
    source += "</html>";

    i'd like to "push" some content into the frames in mozilla. in IE, we
    use the following:
    popupwindow.document.frames['data'].document.write(source);

    but i get an error message that document doesn't exist. i use
    mozilla's debugger and surely there's no document object on the frame
    object. any ideas on how i can push content into these frames?

    thanks!
    ~mark
    , May 25, 2005
    #1
    1. Advertising

  2. wrote:

    > i have a popup window that's built from javascript with something like:
    >
    > source += "<html>";
    > source += " <head>";
    > source += " </head>";
    > source += " <frameset rows='100,*'>";
    > source += " <frame id='controls' name='controls' />";
    > source += " <frame id='data' name='data' />";
    > source += " </frameset>";
    > source += "</html>";
    >
    > i'd like to "push" some content into the frames in mozilla. in IE, we
    > use the following:
    > popupwindow.document.frames['data'].document.write(source);
    >
    > but i get an error message that document doesn't exist. i use
    > mozilla's debugger and surely there's no document object on the frame
    > object. any ideas on how i can push content into these frames?


    I guess it is going to work if you start with
    <frame name='data' src='about:blank'>

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, May 25, 2005
    #2
    1. Advertising

  3. Guest

    i add the src, and it still doesn't seem to work. here's a test html
    page. i had to turn off the pop up blocker in moz, as i couldn't figure
    out how to unblock a local html file.

    <html>
    <head>
    <script language="javascript">

    function init() {
    alert( 'begin' );

    var traceWindow = null;

    try {

    var iwinWidth = 320; // width of the new window
    var iwinHeight = 600; // height of the new window
    var iwinLeft = screen.width - (iwinWidth + 10); //(screen.width /
    2) - (iwinWidth / 2);
    var iwinTop = 10; //(screen.height / 2) - (iwinHeight / 2);
    var sConfig="top=" + iwinTop + ",left=" + iwinLeft +",height=" +
    iwinHeight + ",width=" + iwinWidth + ",scrollbars=yes, resizable=yes";
    var source;

    traceWindow = window.open("","_blank", sConfig);

    source = "";
    source += "<html>";
    source += " <head>";
    source += " </head>";
    source += " <frameset rows='100,*'>";
    source += " <frame id='controls' name='controls'
    src='about:blank'/>";
    source += " <frame id='data' name='data' src='about:blank' />";
    source += " </frameset>";
    source += "</html>";

    traceWindow.document.write(source);
    traceWindow.document.close();

    source = "";
    source += "<html>";
    source += " <head>";
    source += " </head>";
    source += " <body>";
    source += "here";
    source += " </body>";
    source += "</html>";


    traceWindow.document.frames['controls'].document.write(source);

    } catch (ex) {

    alert(ex);

    }


    }

    </script>
    </head>
    <body onload="init();">
    testing
    </body>
    </html>
    , May 25, 2005
    #3
  4. wrote:

    > traceWindow.document.frames['controls'].document.write(source);


    That needs to be
    traceWindow.frames['control'].document.open();
    traceWindow.frames['control'].document.write(...);
    traceWindow.frames['control'].document.close();
    to work with Netscape/Mozilla. Should work that way with IE too.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, May 26, 2005
    #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. Terry
    Replies:
    1
    Views:
    363
    mark | r
    Jan 7, 2004
  2. mark | r
    Replies:
    3
    Views:
    391
  3. Ole Streicher
    Replies:
    14
    Views:
    6,635
    Ole Streicher
    Jun 12, 2008
  4. Fred K.
    Replies:
    2
    Views:
    124
  5. Jeffrey Friedl
    Replies:
    0
    Views:
    131
    Jeffrey Friedl
    Jan 18, 2004
Loading...

Share This Page