For a project I got two select-formfields that get sent via jquery trigger("submit"); This works well in Firefox und Chrome, but in Safari nothing happens.
This is the HTML-Code:
<body>
<form action="http://google.de" target="_blank" style="display: inline;" method="get">
<select class="bstarch2" data-role="none" name="q">
<option value="none">Please choose</option>
<option value="a: worked">A</option>
<option value="b: worked">B</option>
</select>
</form>
<select class="bstarch" data-role="none">
<option value="none">Please choose</option>
<option value="http://google.de">Google</option>
<option value="http://en.wikipedia.org">Wikipedia</option>
</select>
<form action="" method="get" target="_blank" id="mmform"></form>
</body>
And this the Javascript code:
$("body").on("change", ".bstarch", function () {
if ($(this).val() != "none") {
$("#mmform").attr("action", $(this).val());
$("#mmform").trigger("submit");
$(this).val("none");
}
});
$("body").on("change", ".bstarch2", function () {
if ($(this).val() != "none") {
$(this).parent().trigger("submit");
$(this).val("none");
}
});
I got a jsfiddle here, and as well it does not work with Safari: http://jsfiddle.net/P7vNX/
Thanks for any help.
EDIT: Got it: It seems that safari blocks the form submit as a popup. The code is correct, but it gets blocked by Safari... Can't answer my question because my reputation is to small.
Using Safari version 11.1.2 (13605.3.8) on a desktop Mac: if target="_blank" is specified within a form tag, submitting the form fails. That same form works as expected on other browsers. Remove the target="_blank" specification and the form works properly. The same form with target="_blank" does work as expected on other browsers including Chrome, Firefox and IE.
I can only assume this failure to support the "target" attribute is a Safari defect. A possible work-around would be to use "javascript:window.open()" instead of the URL as the action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With