0

I would like to run link mailto:example@example.com on client's side inside controller's action.

How to perform this behaviour? As far as I know I have to run Java Script on their side to perform this.

Users of the site will be small group of IT students so if something has to be done on theirs side first I can manage that.

Yoda
  • 17,363
  • 67
  • 204
  • 344
  • Do you mean you want your controller to generate a `mailto:` link in your view? –  Jul 29 '14 at 22:43

1 Answers1

1

If your question is how can you activate this type of link automatically, via jQuery (which comes with ASP.NET MVC by default), it's easy:

$('#myEmailLink').click();

Obviously, you would either need to add an id to your link or change the selector to pick it out some other way.

If you need to go pure JavaScript, it's a bit more complicated, but there's a nice solution on this StackOverflow question.

Community
  • 1
  • 1
Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
  • Unfortunately it opens a new tab, but works. Thank you. – Yoda Sep 06 '14 at 20:30
  • A mailto link opens in the user's preferred mail client. For a desktop client like Outlook, you'll get the traditional new message window. However its also possible to have a web-based client like Gmail be your default, which would open a new browser tab for Gmail. Either way, though, its not something you can control. Its based on user preferences. – Chris Pratt Sep 06 '14 at 20:35