javascript – 为什么mailto不包含链接参数?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript – 为什么mailto不包含链接参数?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1882字,纯文字阅读大概需要3分钟。
内容图文
![javascript – 为什么mailto不包含链接参数?](/upload/InfoBanner/zyjiaocheng/743/ae704174fa0742d2abd886458b267de4.jpg)
当此代码运行时,警报框会显示包含& list = groceries和& email=tim@sitebuilt.net的链接.当mailto:触发并打开电子邮件窗口时,这些参数丢失了,我无法弄清楚原因.字符串的长度似乎并不重要.
此代码具有运行所需的全部功能.你可以在这里运行它:http://jsfiddle.net/mckennatim/rRerR/
<div data-role="header">
<h1>My Title</h1>
</div><!-- /header -->
<div data-role="content">
<h3>Add List</h3>
<form>
<div data-role="controlgroup" id="addwhat">
<input type="email" id="shemail" name="inp0" class="inp" />
</div>
<div data-role="controlgroup" data-type="horizontal" class="aisubmit">
<input type="submit" data-theme="b" id="mailit" value="mail it"/>
</div>
</form>
</div><!-- /content -->
</div><!-- /page -->
<script>
$('body').on('click', "#mailit", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
repo = "Sebaza";
list = "groceries";
semail = $("#shemail").val();
//(semail);
urri ='mailto:'+ semail + '?subject=share this list with me' + '&cc=' + semail + '&body=Hi, I think it would be cool if we shared this ' + list +' list on our phones. That way when either of us modified it we would see the update. http://10.0.1.18/webeshoppin/stuff2get/www/food2buy.html?repo=' + repo + '&list=' + list + '&email=' + semail ;
window.location = urri;
alert('clicked ashare ' +urri);
});
</script>
</body>
</html>
解决方法:
‘?’和’&’ mailto链接的解析器正在删除字符.
这些字符需要编码.尝试替换为:
? = %3F
& = %26
所以,JS系列看起来像:
urri ='mailto:'+ semail + '?subject=share this list with me' + '&cc=' + semail + '&body=Hi, I think it would be cool if we shared this ' + list +' list on our phones. That way when either of us modified it we would see the update. http://10.0.1.18/webeshoppin/stuff2get/www/food2buy.html%3Frepo=' + repo + '%26list=' + list + '%26email=' + semail;
内容总结
以上是互联网集市为您收集整理的javascript – 为什么mailto不包含链接参数?全部内容,希望文章能够帮你解决javascript – 为什么mailto不包含链接参数?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。