Skip to content

Commit c261723

Browse files
authored
Apply javascript:false only for IE
This seems to fix the reported issue in IE and every browser I tested with.
1 parent 844fe76 commit c261723

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/jquery.form.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
}
126126

127127
/* eslint consistent-this: ["error", "$form"] */
128-
var method, action, url, $form = this;
128+
var method, action, url, isMsie, iframeSrc, $form = this;
129129

130130
if (typeof options === 'function') {
131131
options = {success: options};
@@ -154,12 +154,16 @@
154154
// clean url (don't include hash vaue)
155155
url = (url.match(/^([^#]+)/) || [])[1];
156156
}
157+
// IE requires javascript:false in https, but this breaks chrome >83 and goes against spec.
158+
// Instead of using javascript:false always, let's only apply it for IE.
159+
isMsie = /(MSIE|trident)/.test(navigator.userAgent || '');
160+
iframeSrc = (isMsie && /^https/i.test(window.location.href || '')) ? 'javascript:false' : 'about:blank'; // eslint-disable-line no-script-url
157161

158162
options = $.extend(true, {
159163
url : url,
160164
success : $.ajaxSettings.success,
161165
type : method || $.ajaxSettings.type,
162-
iframeSrc : 'about:blank'
166+
iframeSrc : iframeSrc
163167
}, options);
164168

165169
// hook for manipulating the form data before it is extracted;

0 commit comments

Comments
 (0)