繁体   English   中英

为什么mailto不包含链接参数?

[英]Why won't mailto include link parameters?

当此代码运行时,警报框会显示包含&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;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM