Results 1 to 5 of 5

Thread: close window automatically

  1. #1
    Join Date
    Apr 2007
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default close window automatically

    hello there. i posted this in the "Looking for such a script or service" thread, but i figured it couldn't hurt to ask here too. my apologies if this is frowned upon.

    i have a form that has to post to two different places, and i have a script that does it. only problem is, it has to open a new window to do all the form processing, and i would like that window to close automatically. i'm hoping that all i have to do is add a command to the script that tells it to close the window once the form is processed. here's the script:

    <script>
    <!--
    function submitToTP()
    {
    document.form.action =
    "https://www.topproduceronline.com/LeadToolkit.asp"
    document.form.target =
    "onewindowname"
    document.form.submit();
    }
    function submitToFORM()
    {
    document.form.action =
    "http://www.newhomeconnection.com/forms/fm-test.php"
    document.form.target =
    "onewindowname"
    document.form.submit();
    }


    if anyone has any ideas, i would really appreciate the help!

    thanks!

  2. #2
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    use window.close();
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  3. #3
    Join Date
    Apr 2007
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    thanks!

    but where do i put it? i've tried putting it at the end of script, and at the end of each section of the script, and so far it's not working. i don't really know java, so i'm flying blind here!

  4. #4
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Code:
    function submitToTP()
    {
    document.form.action =
    "https://www.topproduceronline.com/LeadToolkit.asp"
    document.form.target =
    "onewindowname"
    document.form.submit();
    window.opener=self //To stop IE (except IE7) asking to close a window
    window.close() //Bang! And it's gone.
    }
    function submitToFORM()
    {
    document.form.action =
    "http://www.newhomeconnection.com/forms/fm-test.php"
    document.form.target =
    "onewindowname"
    document.form.submit();
    window.opener=self //To stop IE (except IE7) asking to close a window
    window.close() //Bang! And it's gone.
    }
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  5. #5
    Join Date
    Apr 2007
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    thank you so very much!

    i really do appreciate the help.

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
  •