I'm working on a client site to download a PDF after submitting a form by opening the PDF url in a new tab on form submission. But in Chrome, Safari and FF, they're all blocking the "popup". I have noticed a few articles talking about ways to prevent browsers from blocking window.open(). They're usually relating to ajax but I'm not using ajax. The other articles talk about how window.open() only works inside a click event. And even that doesn't work for me.
It doesn't make a ton of sense but in my example I try triggering a click and
<script>
jQuery( document ).ready(function() {
jQuery(".gform_confirmation_message a").on("click", function(e){
e.preventDefault();
var newWin = window.open("", "_blank");
newWin.location = jQuery(".gform_confirmation_message a").attr("href");
});
jQuery(".gform_confirmation_message a").trigger("click");
});
</script>
Even if I put a simple line outside jquery, doesn't work and gets blocked.
var newWin = window.open("", "_blank");
Also either of these on their own do absolutely nothing. It doesn't even bring up the popup blocked.
jQuery(".gform_confirmation_message a").trigger("click");
OR
jQuery(".gform_confirmation_message a").click();
I know browsers are hammering down on spam/ad security but this is ridiculous.