Printing other Frames

Discussion in 'Javascript' started by GodFoca, Jun 7, 2004.

  1. GodFoca

    GodFoca Guest

    Hey all! I have a frameset with two frames, and want to have a button in one
    frame call print() in the other one:

    This is the layout:

    <frameset rows="*,40" frameborder="NO" border="0" framespacing="0">
    <frame src="..." name="pritableText">
    <frame src="..." name="printButton" scrolling="NO" noresize>

    And, in printButton, I got this code:

    <a href="#" onClick="parent.printableText.focus();
    parent.printableText.print();">Print the page</a>

    However, nothing happens in Netscape (7.01) and Firefox (0.8), and in IE (6)
    I get an "error in the script". However, I do not identify the error.

    Does anyone have a clue onto what's happening?

    Thanks in advance,
    Nicolas Sanguinetti
    GodFoca, Jun 7, 2004
    1. Advertisements

  2. GodFoca

    kaeli Guest

    Well, unless you typed wrong, you have a typo in your frameset.
    should be
    (missing 'n')

    Also, I don't think you wanted the parent of the anchor, yet I think
    that's what your code is doing.
    Try this instead
    <a href="#" onClick="window.parent.printableText.focus();
    window.parent.printableText.print();">Print the page</a>

    Note that I don't think that's cross browser. If it doesn't work in
    mozilla / firefox, try
    <a href="#" onClick="window.parent.frames['printableText'].focus();
    window.parent.frames['printableText'].print();">Print the page</a>

    kaeli, Jun 8, 2004
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.