0

I would like to open the following in a new window or tab. Currently it opens in the same window so that after sending the email, the page must be reloaded. This is a part of this webpage

function email_message()
{
   bodytext = document.getElementById("end").value;

   if (bodytext.length > 1850)
   {
      alert("Oops!  The E-Mail Someone button can only be used for short messages, 3 or    less lines of message text.  \nYou can always copy the Encoded Message and past into your regular email!")
      return;
   }
   who_to = prompt("Enter recipient's email address: ","anybody@anywhere.com");
   s_line = "Encoded Message";

   var confirm_send = confirm("Send Email?");
   if (confirm_send == true)
   {
      parent.location.href = 'mailto:' + who_to + '?subject=' + s_line + '&body=' + "Decode at www.mysite.com/myhtml.htm%0D%0D" + bodytext;
   }
   else
   {
   return;
   }
}
Notlikethat
  • 20,095
  • 3
  • 40
  • 77
Rellif
  • 79
  • 1
  • 1
  • 11
  • Have you tried `window.open()` instead of `location.href = `? Or...wait, why is a `mailto:` link opening in the browser at all? Do you have your browser configured for a webmail service, or...? – nnnnnn Mar 08 '14 at 05:48
  • Also, for ppl that have email cilents installed like Outlook, it will open in an Outlook. – user2793390 Mar 08 '14 at 05:49
  • Possible Duplicate of: http://stackoverflow.com/questions/4907843/open-a-url-in-a-new-tab-using-javascript – Nicky Smits Mar 08 '14 at 05:50
  • 1
    You haven't tried Google "javascript open new tab" , please atleast attempt to search for an answer before posting question – Scott Selby Mar 08 '14 at 05:50
  • The user's default email opens in the same page if the default browser is used to view the webpage. If a non-default browser is used, the email opens in the normal default browser, which is fine. Was not aware of "javascript open new tab", but will search dor such. Thanks – Rellif Mar 08 '14 at 06:01
  • @Rellif:try window.open(url, '_blank'); – Sajad Karuthedath Mar 08 '14 at 06:02

1 Answers1

1

Use window.open

You just needs this bit of code below to open the page in a new window,Have tried this

window.open(url, '_blank');
Sajad Karuthedath
  • 14,987
  • 4
  • 32
  • 49