mailto link not working within a frame chrome (over https)

后端 未结 7 1362
梦如初夏
梦如初夏 2020-12-09 02:25

I have a mailto link on a page. It works as expected when the page is loaded by itself.

However when the page is loaded via a frameset in Chrome nothing happens. Wit

相关标签:
7条回答
  • 2020-12-09 02:52

    Yes, using "top" is the trick, but you can do it with HTML alone!

    <a target="_top" href="mailto:...">email</a>
    
    0 讨论(0)
  • 2020-12-09 02:52

    add target="_top" or "_blank" or "_parent"

    <a target="_top" href="mailto:a@b.c">email1</a>

    <a target="_top" href="mailto:a@b.c">email2</a>

    0 讨论(0)
  • 2020-12-09 02:54

    Possibly because your parent frameset is https, but Chrome now seems to treat the mailto link as insecure.

    I just came across a similar issue when triggering a mailto link via

    window.location = 'mailto:...'
    

    Changing it to this worked around it.

    window.open( 'mailto:...')
    
    0 讨论(0)
  • 2020-12-09 02:54

    This is my workaround until Chrome bug is fixed:

    $.browser.chrome = /chrom(e|ium)/.test(navigator.userAgent.toLowerCase()); 
    
    if($.browser.chrome){
         myWindow=window.open("mailto:"+eml+"?subject="+msb,'','width=50,height=50');
         myWindow.close();
    } else {
        window.location.href = "mailto:"+eml+"?subject="+msb;
    }
    

    For Chrome, make instance with window.open() method and close that instance immediately. Small window will "blink" for a short period but will do the job. It is "dirty" solution but as much as Chrome's bug.

    For other browsers window.location() method can be used.

    0 讨论(0)
  • 2020-12-09 03:09

    I also had this issue recently with an iframe. Using the top frame worked and should be compatible with all major browsers.

    window.top.location = 'mailto:...';
    
    0 讨论(0)
  • 2020-12-09 03:14

    Here is the solution I ended up with: Tested with Chrome, Firefox, IE6, IE7, IE8, IE9, IE10, IE11, Safari

    $("a[href^='mailto:']").on("click",function() {
        window.top.location = $(this).prop("href");
        return false;
    });
    
    0 讨论(0)
提交回复
热议问题