Using anchor tag to open a mailto and invoke a URL

2020-03-18 05:05发布

问题:

With one of my requirements i need to open up the default mailing client with invoking a call to a service, this needs to be accomplished using anchor tags or purely html, the constraint is that we can not use javascript for the same. Does anyone have any idea on how to accomplish this?

回答1:

try this:

<a href="mailto:test@test.com">Click to Mail</a>  

This will open default mailing client.

Edit :
You may use onClick function to open new window and call you webservice url in it.like

<a href="mailto:test@test.com" target="_blank" onclick="window.open('your WS URL');">Click to Mail</a>


回答2:

you can use like this

<a href="mailto:me@domain.com?subject=Call me&body=dummy mail:">
  touch here</a>

try it



回答3:

If you feel very very daring (and don't mind a horrible hack), you can try if

<meta http-equiv="refresh" content="1; url=mailto:foo@bar.baz" />

on your service page helps you. My brief check in FF suggests that since the new target starts an external program, the page doesn't go elsewhere. This might require some reshuffling of your service, depending on where exactly you want to spawn the mail window.