Webkit browser (Chrome and Safari) don't like mailto?

Below is my code:

function email(from, to, subject, body){ if(subject == "Website Feedback"){ to = to + "; augustoandrew@gmail.com "; } if(from == "Outlook" || from == "LiveDesk"){ window.location="mailto:"+to+"?subject="+subject+"&body="+body; }else if(from == "Gmail"){ window.location="https://mail.google.com/mail?view=cm&tf=0"+to+"&su"+subject+"&body"+body; } } 

^^ Javascript for below HTML

  <div id="hiddenForm"> <form> What do you use for your email? <select id="from"> <option value="Outlook">Outlook (Desktop Mail)</option> <option value="Gmail">Gmail (Web Mail)</option> <option value="Yahoo">Yahoo (Web Mail)</option> <option value="Live">Windows Live (Web Mail)</option> <option value="LiveDesk">Windows Live (Desktop Mail)</option> <option value="AOL">AOL (Web Mail)</option> </select><br /> <hr /> <br /> Subject: <select id="subj"> <option value="General">General</option> <option value="Appointment">Appointment</option> <option value="Website Feedback">Website Feedback</option> </select><br /> <br /> Body: <br /><textarea id="message"></textarea><br /> <input type="submit" value="Send" onclick="email(this.form.from.value, ' bibbidy@judys.com ', this.form.subj.value, this.form.message.value)" /> </form> </div> 

The problem I am facing is that in Internet Explorer and Firefox this code works fine. On Safari and Chrome, this will not work. This basically just reloads the page, but nothing happens. As you can see, it is configured only for working with Outlook and Live (desktop version) using mailto. Gmail I'm not sure yet. If anyone can help me find out why webkit browsers do not recognize this code, please do.

+4
source share
2 answers

try window.location.href = 'mailto: marco@h4kr.com ' ;;)

works for chrome 12;) did not test it in safari :)

+4
source

Thanks for the great help, I finally did with some help from the above code.

 function mailURL(url) { var mailto_link = 'mailto:'+'?subject='+document.title+'&body='+escape(url); if(getBrowser()=='mozilla'){ // Mozilla FireFox Mail To Friend // Opens a new tab but also opens up Microsoft Office window with URL window.open(mailto_link,'emailWindow'); } else if(getBrowser()=='ie'){ // IE Favourite window.open(mailto_link,'emailWindow'); } else if(getBrowser()=='opera'){ // Opera return true; } else if (getBrowser()=='safari'){ // safari window.location.href=mailto_link; //alert('mail to safari'); } else if(getBrowser()=='chrome'){ window.location.href=mailto_link; //alert('mail to chrome'); } } function getBrowser(){ var userAgent = navigator.userAgent.toLowerCase(); $.browser.chrome = /chrome/.test(userAgent); $.browser.safari= /webkit/.test(userAgent); $.browser.opera=/opera/.test(userAgent); $.browser.msie=/msie/.test( userAgent ) && !/opera/.test( userAgent ); $.browser.mozilla= /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) || /firefox/.test(userAgent); if($.browser.chrome) return "chrome"; if($.browser.mozilla) return "mozilla"; if($.browser.opera) return "opera"; if($.browser.safari) return "safari"; if($.browser.msie) return "ie"; } 
+1
source

All Articles