移动电子邮件启动+点击事件重定向

Mobile email launch + onclick event for redirect

本文关键字:事件 重定向 电子邮件 启动 移动      更新时间:2023-09-26

我有如下简单的文字,在手机上有2件事的功能:

  1. 使用预先填充的主题和正文打开电子邮件
  2. onclick函数将用户重定向到指定URL
一个类似的网站是这样做的:http://app.mobileoptin.com/c2926/advertlines

在上面的示例中,在移动浏览器中,如果用户单击"Click Here For Access"按钮,它将:

  1. 打开邮件移动客户端,文本
  2. 将用户在后台重定向到特定的URL

这正是我需要的。

CODE I HAVE:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <script type="text/javascript">
                function Redirect() {
                 window.location.href="http://www.google.com";   
            }
        </script>
    </head>
    <body>
        <a href="mailto:test@theearth.com?subject=Circle Around&body=Some blah" name="redirect" onclick="Redirect();">Email</a>
    </body>
</html>

它在台式机上运行良好,但由于某些原因,我不能让它在移动设备上运行,至少在android上。

感谢您的建议,如果有更好的方法,欢迎您提出建议。

 /// add here your url link
    String url = "http://www.xxxxxxxx.com/apply";
    SpannableStringBuilder builder = new SpannableStringBuilder();
    builder.append("hi friends please visit my website for");
    int start = builder.length();
    builder.append(url);
    int end = builder.length();
    builder.setSpan(new URLSpan(url), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
      Intent i = new Intent(Intent.ACTION_SEND);
      i.setType("message/rfc822");
      i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"abcd@gmail.com"});
      i.putExtra(Intent.EXTRA_SUBJECT, "subject of email is this");
      i.putExtra(Intent.EXTRA_TEXT, builder);
       try {
        startActivity(Intent.createChooser(i, "Send mail..."));
           } catch (android.content.ActivityNotFoundException ex) {
      Toast.makeText(MainActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
    }