查找GPS位置并将电子邮件发送到特定地址 [英] Find GPS location and send email to a specific address
本文介绍了查找GPS位置并将电子邮件发送到特定地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用此代码在我的iphone上找到GPS位置:
I use this code to find the GPS location on my iphone:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>GPS</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<script>
navigator.geolocation.getCurrentPosition(foundLocation, noLocation);
function foundLocation(position)
{
var lat = position.coords.latitude;
var long = position.coords.longitude;
alert('Found location: ' + lat + ', ' + long);
}
function noLocation()
{
alert('Could not find location');
}
</script>
</body>
</html>
以上效果很好,弹出十进制lat并且长在警报框中。
但是,我无法弄清楚该怎么做,是将lat / long位置发送到嵌入的电子邮件地址,在代码中硬连线。由于lat和long已经可用作变量,我想我只需要知道这些变量是否可以分配给发送电子邮件的脚本。
谢谢,Rich
The above works well, popping up the decimal lat and long in an alert box.
What I can't figure out how to do, though, is to send the lat/long location to an email address embedded, hardwired, in the code. Since the lat and long are already available as variables, I guess I just need to know if those variables can be assigned to a script that sends the email.
Thanks, Rich
推荐答案
如果您只是想直接发送电子邮件,为什么不使用MAILTO方法?那么,你会有
If you just want to send the email directly, why not use the MAILTO method? So, you would have
mailto:user@domain.com?body=encodeURIComponent('Found location: ' + lat + ', ' + long);
doc write code只是一个发送按钮。
脚本有两个部分。
第1部分确定GPS位置。
第2部分将该信息通过电子邮件发送到固定的电子邮件地址。
每个脚本都作为独立功能运行,但我无法让这两个部分协同工作。就是这样。
The "doc write code" is just meant to be a send button.
The script has two parts.
Part #1 determines the GPS location.
Part #2 emails that information to a fixed email address.
EACH of the scripts work as stand alone functions, but I am unable to get the two parts to work together. That's about it.
这篇关于查找GPS位置并将电子邮件发送到特定地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文