Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why won't mailto include link parameters?

When this code runs the alert box comes up with the link that includes &list=groceries and &[email protected]. When the mailto: fires and brings up the email window those parameters are missing and I can't figure out why. the length of the string doesn't seem to matter.

This code has all it needs to run. You can run it here: 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>
like image 263
mcktimo Avatar asked Dec 28 '22 06:12

mcktimo


1 Answers

The '?' and '&' characters are being stripped out by the parser of the mailto link.

Those characters need to be encoded. Try replacing with:

? = %3F
& = %26

so, that JS line would look like:

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;
like image 193
Patrick Shafer Avatar answered Jan 11 '23 05:01

Patrick Shafer