Reputation: 533
I have created a traditional file upload using form and iframe. My html:
<form id="theuploadform">
<div class="form-group">
<input id="importFile" name="file" size="50" type="file" />
</div>
</form>
The javascript:
var iframe = $('<frame name="postiframe" id="postiframe" style="display: none"></frame>');
$("body").append(iframe);
var form = $('#theuploadform');
form.attr("action", "/uploadhandler.ashx");
form.attr("method", "post");
form.attr("encoding", "multipart/form-data");
form.attr("enctype", "multipart/form-data");
form.attr("target", "postiframe");
form.attr("file", $('#userfile').val());
form.submit();
Now it will post to UploadHandler.ashx
that will write the contents of the file to the iframe:
context.Response.ContentType = "text/plain";
context.Response.Write(new StreamReader(file.InputStream).ReadToEnd());
My problem here is that the iframe content is being rendered different on ie9 and ie11.
IE11:
<iframe>
<!DOCTYPE html>
<body>
<pre>
// xml content here //
</pre>
IE9:
<iframe>
<Nodename xmlns:xsd="http://www.w3.org/2001/XMLSchema">
Any thoughts to make the iframe same as on IE11?
EDIT
I have the following code on my _Layout.cshtml
:
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
Upvotes: 0
Views: 484
Reputation: 74738
Try adding a meta tag for IE:
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
It forces the browser the render at whatever the most recent version's standards are. Just like using the latest version of jQuery on Google's CDN, this is the most recent, but also can potentially break your code since its not a fixed version.
or you could be more specific with IE9
:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
or
<meta http-equiv="X-UA-Compatible" content="IE=IE9" />
Checkout a detailed answer from here.
Upvotes: 1