簡體   English   中英

從razor視圖啟動電子郵件客戶端

[英]Launching the e-mail client from razor view

我有一個ASP.NET MVC4應用程序,其中有以下視圖:

@{
    Layout = "~/Views/Shared/Template.cshtml";
}
@section logout {

    <a href='@Url.Action("Logout", "Begin")' style="margin-left: 91.3%"><img src="~/Content/images/images.jpg" style="width:37px; height:37px" /></a>
    }
<html>
<head>
    <script>
        function mailJob(code) {
            window.open('mailto:example@gmail.com');
        }
    </script>

    </head>
    <body>

<form action="/Pages/Index" method="post" style="margin-left:20%">
    <div class ="CenterTitle">
        <h1 style="color:rgb(73, 140, 212)">Norm impact : Registre des réclamations clients</h1>
    </div>
    <div class="noPrint">
         <input type="hidden" value ="1" name="Pages"/>
                <button type="submit" value="Submit" name="btnPage1"><img src="~/Content/images/OK.png" onclick="mailJob('Sample');"/></button>
                <button type="button" value="exportToPDF" onclick="window.print()" name="btnPage1"style="margin-left:55%"><img src="~/Content/images/print.png" /></button>
    </div>

    ...

    <div class="noPrint">
        <button type="submit" value="Page2" name="btnPage1" style="margin-left:75%"><img src="~/Content/images/next.png" /></button>
    </div>
</form>

</body></html>

問題出在mailto因為郵寄軟件未啟動,而是一個新窗口,其URL為mailto:example@gmail.com

那么我該如何解決這個問題呢?

嘗試以下方法:

function mailJob(code) {
    window.location.href = 'mailto:example@gmail.com';
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM