Html 使用锚标记打开一个mailto并调用一个URL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20373420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:20:46  来源:igfitidea点击:

Using anchor tag to open a mailto and invoke a URL

htmlanchorhrefmailto

提问by vaibhav

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?

根据我的要求之一,我需要通过调用服务调用来打开默认邮件客户端,这需要使用锚标记或纯 html 来完成,限制是我们不能使用 javascript。有没有人知道如何做到这一点?

回答by Yagnesh Agola

try this:

尝试这个:

<a href="mailto:[email protected]">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

编辑:
您可以使用 onClick 函数打开新窗口并在其中调用您的 webservice url.like

<a href="mailto:[email protected]" target="_blank" onclick="window.open('your WS URL');">Click to Mail</a>

回答by Raj the Starter

you can use like this

你可以这样使用

<a href="mailto:[email protected]?subject=Call me&body=dummy mail:">
  touch here</a>

try it

尝试一下

回答by Ulrich Schwarz

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:[email protected]" />

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.

在您的服务页面上可以帮助您。我对 FF 的简短检查表明,由于新目标启动了一个外部程序,因此该页面不会转到其他地方。这可能需要重新调整您的服务,具体取决于您想要生成邮件窗口的确切位置。