模式对话框中加载的页面不起作用
我在模式对话框中加载了 Example.ascx 页面,代码如下,但在 Google Chrome 中遇到了一个问题。当Example.ascx在模式对话框中加载时,其功能停止工作,我无法浏览和上传文件(Example.ascx页面是基于plupload的文件上传页面)。 Google Chrome 是这样说的:资源解释为“其他”,但以未定义的 MIME 类型传输。
Index.aspx:
<script type="text/javascript">
$(function() {
$('#dialog').html("")
$('#dialog').dialog({
autoOpen: false,
width: 400,
resizable: true,
title: 'Upload',
modal: true,
open: function(event, ui) {
$(this).load("../Admin/example");
},
buttons: {
"Close": function() {
$(this).dialog("close");
}
}
});
$('#my-button').click(function() {
$('#dialog').dialog('open');
});
});
</script>
<input type="button" id="my-button" name="my-button" value="klikni"/>
<div id="dialog" title="My dialog" >
Example.ascx页面:
<div id="container">
<div id="filelist">No runtime found.</div>
<br />
<a id="pickfiles" href="javascript:;">[Select files]</a>
<a id="uploadfiles" href="javascript:;">[Upload files]</a>
</div>
<script type="text/javascript">
// Custom example logic
function $(id) {
return document.getElementById(id);
}
var uploader = new plupload.Uploader({
runtimes: 'gears,html5,flash,silverlight,browserplus',
browse_button: 'pickfiles',
container: 'container',
max_file_size: '10mb',
url: '../Admin/Upload',
resize: { width: 320, height: 240, quality: 90 },
flash_swf_url: '../../Scripts/plupload/plupload.flash.swf',
silverlight_xap_url: '../../Scripts/plupload/plupload.silverlight.xap',
filters: [
{ title: "Image files", extensions: "jpg,gif,png" },
{ title: "Zip files", extensions: "zip" }
]
});
uploader.bind('Init', function(up, params) {
$('filelist').innerHTML = "<div>Current runtime: " + params.runtime + "</div>";
});
uploader.bind('FilesAdded', function(up, files) {
for (var i in files) {
$('filelist').innerHTML += '<div id="' + files[i].id + '">' + files[i].name + ' (' + plupload.formatSize(files[i].size) + ') <b></b></div>';
}
});
uploader.bind('UploadProgress', function(up, file) {
$(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
if (file.percent == 100) window.location.href = "../Admin/Index";
});
$('uploadfiles').onclick = function() {
uploader.start();
return false;
};
uploader.init();
I'm loaded Example.ascx page in modal dialog with code below and have one problem in Google Chrome. When Example.ascx loaded in modal dialog its functionality stop work and I can't browse and upload files (Example.ascx page is file upload page based on plupload). Google chrome says this:Resource interpreted as Other but transferred with MIME type undefined.
Index.aspx:
<script type="text/javascript">
$(function() {
$('#dialog').html("")
$('#dialog').dialog({
autoOpen: false,
width: 400,
resizable: true,
title: 'Upload',
modal: true,
open: function(event, ui) {
$(this).load("../Admin/example");
},
buttons: {
"Close": function() {
$(this).dialog("close");
}
}
});
$('#my-button').click(function() {
$('#dialog').dialog('open');
});
});
</script>
<input type="button" id="my-button" name="my-button" value="klikni"/>
<div id="dialog" title="My dialog" >
Example.ascx page:
<div id="container">
<div id="filelist">No runtime found.</div>
<br />
<a id="pickfiles" href="javascript:;">[Select files]</a>
<a id="uploadfiles" href="javascript:;">[Upload files]</a>
</div>
<script type="text/javascript">
// Custom example logic
function $(id) {
return document.getElementById(id);
}
var uploader = new plupload.Uploader({
runtimes: 'gears,html5,flash,silverlight,browserplus',
browse_button: 'pickfiles',
container: 'container',
max_file_size: '10mb',
url: '../Admin/Upload',
resize: { width: 320, height: 240, quality: 90 },
flash_swf_url: '../../Scripts/plupload/plupload.flash.swf',
silverlight_xap_url: '../../Scripts/plupload/plupload.silverlight.xap',
filters: [
{ title: "Image files", extensions: "jpg,gif,png" },
{ title: "Zip files", extensions: "zip" }
]
});
uploader.bind('Init', function(up, params) {
$('filelist').innerHTML = "<div>Current runtime: " + params.runtime + "</div>";
});
uploader.bind('FilesAdded', function(up, files) {
for (var i in files) {
$('filelist').innerHTML += '<div id="' + files[i].id + '">' + files[i].name + ' (' + plupload.formatSize(files[i].size) + ') <b></b></div>';
}
});
uploader.bind('UploadProgress', function(up, file) {
$(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
if (file.percent == 100) window.location.href = "../Admin/Index";
});
$('uploadfiles').onclick = function() {
uploader.start();
return false;
};
uploader.init();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在使用 plupload 和 jQuery UI 对话框时遇到了同样的问题,它在某些浏览器中有效,但在其他浏览器中无效。
我能够通过调用来解决这个问题:
在调用打开对话框之后立即调用。
I had the same problem using the plupload with a jQuery UI dialog where it works in some browsers and not in others.
I was able to solve it by calling:
right after the call to open the dialog.