From below code, the alert function should be executed after the form submit.But it executes at first time, after that it won't.It executes fine in all browsers except IE11.
Code:
<iframe id="iframeID">
<form id="profile">
<input type="file" id="UPLOADED_FILE" name="UPLOADED_FILE" value="" >
<input type="submit" name="save_photo" value="Save" onclick="pressUpload();">
</form>
</iframe>
function pressUpload() {
var iframe_document = document.getElementById('iframeID').contentWindow.document;
var form_profile = $(iframe_document).find('#profile');
var file_input_field = $(form_profile).find('input[name=UPLOADED_FILE]');
$(file_input_field).bind('change', function () {
var value = $(this).val();
if (value) {
$(form_profile).submit();
if (navigator.userAgent.indexOf("MSIE") > -1 && !window.opera) {
iframe.onreadystatechange = function () {
if (iframe.readyState == "complete") {
alert("HI");
}
};
}
}
})
}
That is invalid way to write markup.
but you should not use any element between iframe's opening/closing tags like you have done in your case.
Actually that only gets executed when this element is not supported in any browser. @MDN you can see the example1
<iframe src="page.html" width="300" height="300">
<p>Your browser does not support iframes.</p>
</iframe>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.