Javascript 为什么赢了';Mailt是否包含链接参数?

Javascript 为什么赢了';Mailt是否包含链接参数?,javascript,jquery-mobile,Javascript,Jquery Mobile,当此代码运行时,警报框会显示包含&list=杂货和&email的链接=tim@sitebuilt.net. 当mailto:启动并打开电子邮件窗口时,这些参数丢失了,我不知道为什么。绳子的长度似乎无关紧要 <div data-role="header"> <h1>My Title</h1> </div><!-- /header --> <div

当此代码运行时,警报框会显示包含&list=杂货和&email的链接=tim@sitebuilt.net. 当mailto:启动并打开电子邮件窗口时,这些参数丢失了,我不知道为什么。绳子的长度似乎无关紧要

        <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>
这段代码具有运行所需的全部功能。您可以在此处运行它:

        <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>

我的头衔
添加列表
$('body')。在('click',“#mailit”,函数(e){
e、 停止即时复制();
e、 预防默认值();
repo=“Sebaza”;
list=“杂货”;
语义=$(“#shemail”).val();
//(塞梅尔);
urri='mailto:'+semail+'?subject=与我共享此列表'+'&cc='+semail+'&body=Hi,我认为如果我们在手机上共享此'+list+'列表会很酷。这样,当我们中的任何一方修改它时,我们都会看到更新。http://10.0.1.18/webeshoppin/stuff2get/www/food2buy.html?repo=“+repo+”&list=“+list+”&email=”+semail;
window.location=urri;
警报(“已点击的ashare”+urri);
});          

mailto链接的解析器正在删除“?”和“&”字符

        <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>
这些字符需要编码。尝试替换为:

        <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>
? = %3F
& = %26
因此,JS行看起来像:

        <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>
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;

这个演示程序(使用
window.open()
)在Firefox中没有使用Gmail发送电子邮件的编码:这很有趣,因为我一直在使用google notifier混乱注册表设置,仍然无法阻止windows live mail打开。唉,我试过你的cose,但它仍然打开了windows。帕特里克是对的。额外的URL参数被连接到整个mailto URL,并被视为mailto协议的未定义部分,因此它们只是失效。如果你像Patrick建议的那样逃避它们,那么它们将融入并成为body参数的一部分。没有说明你使用的是什么电子邮件客户端——并不是所有的客户端都支持这些额外的参数(我知道,因为我写的那一个不支持…。我有一天会加上它)