【问题标题】:How to download PDF after fadeout the success message?淡出成功消息后如何下载PDF?
【发布时间】:2017-11-17 13:44:43
【问题描述】:

我正在使用表单向用户提交电子邮件和姓名。提交表单后触发电子邮件并显示成功消息。成功消息在 10 秒后淡出,即很好。现在我想在淡出成功消息后也下载一个 pdf。

我正在通过行动实现这一目标。

我正在使用以下代码:

<form class="brochure brochure_1" method="post" id="custom_contact_form" action="http://example.com/contact/index/contact" onsubmit="return validateForm();" name="myForm">
        <div class="input-box">
            <input type="hidden" readonly="readonly" class="input-text required-entry toname" value="" name="toname"/>
            <input type="hidden" value="<?php echo $this->getFromUrl(); ?>" name="submiturl" class="submiturl" />
        </div>
            <input type="text" class="input-text required-entry" value="" name="name" placeholder="Name"/>
            <input type="text" class="input-text required-entry" value="" name="email" placeholder="Email"/>
        <span><input type="submit" value="Download" /></span>
    </form>
<script>
function validateForm() {
    var name = document.forms["myForm"]["name"].value;
    if (name == "") {
        alert("Name must be filled out");
        return false;
    }

    var email = document.forms["myForm"]["email"].value;
    var atpos = email.indexOf("@");
    var dotpos = email.lastIndexOf(".");
    if (email == "") {
        alert("Email must be filled out");
        return false;
    }
    else if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) {
        alert("Not a valid e-mail address");
        return false;
    }
}

jQuery('.success-msg').insertBefore(jQuery( ".breadcrumbs" ));
 jQuery(document).ready(function(){
        setTimeout(function() {
          jQuery('.success-msg').fadeOut('fast');
        }, 10000); // <-- time in milliseconds
    });
</script>

【问题讨论】:

  • 在下面写你的代码 jQuery('.success-msg').fadeOut('fast');

标签: php email magento controller


【解决方案1】:

像这样替换准备好的文档,

 jQuery(document).ready(function(){
        setTimeout(function() {
          jQuery('.success-msg').fadeOut('fast');
        }, 10000); // <-- time in milliseconds
window.location.href = href; //causes the browser to refresh and load the requested url, Put the url to download pdf here.
    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-26
    • 1970-01-01
    • 2017-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多