Results 1 to 4 of 4

Thread: print outside the iframe?

  1. #1
    Join Date
    Nov 2007
    Posts
    151
    Thanks
    67
    Thanked 0 Times in 0 Posts

    Default print outside the iframe?

    Hi

    I have a simple iframe inside a table. This iframe includes a php form, that after sending it, should print a simple message outside the iframe (in the page, I don't care where..)

    Can JavaScript help me to print it outside the iframe?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Don't you mean when submitting the form? And you don't really mean print, except from the programming point of view, right? If I've got that right - say this is the beginning of your form in your iframe:

    Code:
    <form action="whatever" method="whatever" 
    onsubmit="top.document.getElementById('form_response').firstChild.nodeValue = 
    'Some simple message';return true;">
    And on your top page you have:

    Code:
    <div id="form_response">&nbsp;</div>
    it should all work out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I just tested this out to be sure and it works fine, except in FF if you refresh the top page and submit again there is an error. This can be avoided by a short script on the top page that refreshes the iframe to its original source on reload of the top page. Here are my two pages, added code highlighted -

    top page:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
    window.onload = function(){
    document.getElementById('form_frame').src = 'form.htm';
    }
    </script>
    </head>
    <body>
    <iframe id="form_frame" src="form.htm" width="300" height="300" scrolling="auto" frameborder="1"></iframe>
    <div id="form_response">&nbsp;</div>
    </body>
    </html>
    form.htm:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    </head>
    <body>
    <form action="#" 
    onsubmit="top.document.getElementById('form_response').firstChild.nodeValue = 
    'Some simple message';return true;">
    <input type="submit" value="Go">
    </form>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. The Following User Says Thank You to jscheuer1 For This Useful Post:

    d-machine (07-17-2008)

  5. #4
    Join Date
    Nov 2007
    Posts
    151
    Thanks
    67
    Thanked 0 Times in 0 Posts

    Default

    Thank you very much !!!!!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •