0

I'm trying to create a simple link to open a mailto box to allow a user to send feedback, within a widget. My code look like this:

content: '<p>We welcome questions and comments! Send feedback to Name (<a style="color:white" class="email" title="Send feedback" href="javascript:window.location=&quot;mailto:name@domain.com&quot; + window.location;" >name@domain.com</a>).</p>'

I also tried:

content: '<p>We welcome questions and comments! Send feedback to Sean Barbeau (<a style="color:white" class="email" title="Send feedback" href="mailto:barbeau@cutr.usf.edu" >barbeau@cutr.usf.edu</a>).</p>'

I got this syntax from here: How to write in 'mailto' body link to current page

I read how to deal with nested here: Nesting quotes in JavaScript/HTML

My problem is that in chrome this code opens a new browser page. I haven't been able to understand why it behaves this way since my knowledge in javascript is a bit limited.

I would like to understand what I did wrong and how to fix it.

Community
  • 1
  • 1
user1527152
  • 946
  • 1
  • 13
  • 37

2 Answers2

3

This code will open whatever default mail service the user has. Since I have outlook set as the default, it opens an Outlook window for me. If you have a web-based email setup as your default email service, it will open a new window with your service initiated. That's the inherit behavior of a mailto link.

Christian Hill
  • 378
  • 1
  • 3
  • 17
  • If you want to provide a consistent experience for everyone, you'll need to link to a form that sends the feedback server-side instead of using a mailto link. – Tim Mar 09 '16 at 15:04
  • From your answer I think I understand that my problem is actually that in chrome I don't have an email setup as my default email service. Thank you – user1527152 Mar 09 '16 at 15:10
0

You could use mail() function of PHP.

You create a simple form for users where they need to insert the message they want to send you and a submit button, then this form calls the mail.php that contains mail() function. It's so easy, you could see tutorials on youtube, If you want I could teach you, actually I'm using it on my website.