/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Close mailto tab

Hi all,

I have run into a issue where when I have a javascript function which opens a window to a mailto tab, in firefox and chrome blank tabs appear. Outlook opens and all the information is there, but I would like the new tab to automatically close like it does in IE.

This is my code so far:

<script type=”text/javascript”>
function open_win() {
var dropList = document.forms[0][‘ProdDropClient’];

window.open(“mailto:” + document.forms[0][‘EmailBox’].value + “?subject=Key&body=Hi,%0D%0A%0D%0ARegistered Company Name: ” + document.forms[0][‘NameBox’].value + “%0D%0AProduct : ” + dropList.options[parm.selectedIndex].text + “%0D%0AKey Generated : ” + document.forms[0][‘KeyBox’].value + “%0D%0A%0D%0AThanks,%0D%0AWinfreight”);

}

</script>

I have tried the following options,

  • 1. window.opener.close();

  • 2. setTimeout(“window.close()”, 5000);

  • 3. self.close();
  • and a couple others. I created a seperate javascript function which will close a window which I then called after I had executed the open window function, but that didn’t work either. I just have no idea how to fix this. Any help would be MUCH appreciated, thanks

    to post a comment
    JavaScript

    1 Comments(s)

    Copy linkTweet thisAlerts:
    @FrijxauthorSep 25.2013 — Ok I figured it out ?

    here is code:

    <script type="text/javascript">

    function close_win() {

    mail.close();

    }

    function open_win() {

    var dropList = document.forms[0]['ProdDropClient'];

    mail = window.open("mailto:" + document.forms[0]['EmailBox'].value + "?subject=Key&body=Hi,%0D%0A%0D%0ARegistered Company Name: " + document.forms[0]['NameBox'].value + "%0D%0AProduct : " + dropList.options[dropList.selectedIndex].text + "%0D%0AKey Generated : " + document.forms[0]['KeyBox'].value + "%0D%0A%0D%0AThanks,%0D%0AWinfreight");

    close_win();

    }

    </script>
    ×

    Success!

    Help @Frijx spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.19,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...