分享2個(gè)jQuery插件--jquery.fileupload與artdialog
這些是我們項(xiàng)目中必不可少的東西,所以今天推薦兩個(gè)一個(gè)叫做artdialog是個(gè)iframe的jquery插件,一個(gè)叫jquery file upload,我看網(wǎng)上很少有這個(gè)插件jquery file upload的插件使用教程,今天我就簡(jiǎn)單的介紹和寫一點(diǎn)使用的方法!
簡(jiǎn)單用代碼舉例子
最小化的方法
data-url是上傳后執(zhí)行上傳文件的php方法
<input id="fileupload" type="file" name="files[]" data-url="server/php/" multiple>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/vendor/jquery.ui.widget.js"></script>
<script src="js/jquery.iframe-transport.js"></script>
<script src="js/jquery.fileupload.js"></script>
<script>
$(function () {
$('#fileupload').fileupload({
dataType: 'json', //josn傳輸
done: function (e, data) { //上傳結(jié)束后執(zhí)行
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo(document.body);
});
}
});
});
</script>
稍微擴(kuò)展一下
<input id="fileupload" type="file" name="files[]" multiple>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/vendor/jquery.ui.widget.js"></script>
<script src="js/jquery.iframe-transport.js"></script>
<script src="js/jquery.fileupload.js"></script>
<script>
$(function(){
//完整的API在這里https://github.com/blueimp/jQuery-File-Upload/wiki/API 我就是簡(jiǎn)單的介紹一些常用的說(shuō)明
$("#fileupload").fileupload('option',{ //設(shè)置上傳事件
url: 'http://localhost/php/index.php' //指定php上傳方法
disableImageResize: /Android(?!.*Chrome)|Opera/
.test(window.navigator.userAgent), //禁止生成縮略圖
maxFileSize : 5000000 //設(shè)置支持的最大尺寸
acceptFileTypes: /(\.|\/)(rar|zip|jp?g|png|bmp)$/i, //設(shè)置上傳的類型
});
$.ajax({
url: $('#fileupload').fileupload('option', 'url'), //根據(jù)設(shè)置選項(xiàng)ajax傳輸
dataType: 'json',
context: $('#fileupload')[0]
}).done(function (result) {
$(this).fileupload('option','done'
).call(this, $.Event('done'), {result: result}); //上傳完成后做的事情
});
$('#fileupload').bind('fileuploaddone',function(e,data){ //綁定上傳完執(zhí)行的事件
$.each(data.result.files , function (index ,file){
for(var i in file){
alert(i+':'+file[i])
}
});
//綁定的事件太多了 大家直接翻譯過(guò)來(lái)就明白是什么意思
$('#fileupload')
.bind('fileuploadadd', function (e, data) {/* ... */})
.bind('fileuploadsubmit', function (e, data) {/* ... */})
.bind('fileuploadsend', function (e, data) {/* ... */})
.bind('fileuploaddone', function (e, data) {/* ... */})
.bind('fileuploadfail', function (e, data) {/* ... */})
.bind('fileuploadalways', function (e, data) {/* ... */})
.bind('fileuploadprogress', function (e, data) {/* ... */})
.bind('fileuploadprogressall', function (e, data) {/* ... */})
.bind('fileuploadstart', function (e) {/* ... */})
.bind('fileuploadstop', function (e) {/* ... */})
.bind('fileuploadchange', function (e, data) {/* ... */})
.bind('fileuploadpaste', function (e, data) {/* ... */})
.bind('fileuploaddrop', function (e, data) {/* ... */})
.bind('fileuploaddragover', function (e) {/* ... */})
.bind('fileuploadchunksend', function (e, data) {/* ... */})
.bind('fileuploadchunkdone', function (e, data) {/* ... */})
.bind('fileuploadchunkfail', function (e, data) {/* ... */})
.bind('fileuploadchunkalways', function (e, data) {/* ... */});
});
});
</script>
由于這個(gè)插件功能很強(qiáng)大,方法和API太多大家可以先看看官網(wǎng)的APi,當(dāng)然有不懂的也可以問(wèn)問(wèn)我!
第二個(gè)這個(gè)其實(shí)很簡(jiǎn)單artdialog,國(guó)人開發(fā)的,所有的API都是漢語(yǔ)的,所以同學(xué)們一看就會(huì)了,這里我就說(shuō)一個(gè)的了,就是iframe關(guān)閉如何傳輸數(shù)據(jù)呢?
<script src="jquery.mini.js"></script>
<script src="artDialog.js?skin=default"></script>
<script src="./plugins/iframeTools.js"></script>
<script src="./skins/idialog.css"></script>
<title>jquery的處理</title>
</head>
<script>
function nihao(){
art.dialog.open( //打開一個(gè)iframe遠(yuǎn)程文件
"http://localhost/dialog/index2.html",
{
title :"測(cè)試的頁(yè)面",
width: 320,
height: 400,
close : function(){
//iframe關(guān)閉時(shí)執(zhí)行的
alert("my god 關(guān)閉了")
}
}
);
}
</script>
<body>
<input type="text" id="nihao" value="測(cè)試數(shù)據(jù)"/>
<a href="javascript::nihao()" onclick="nihao()">提交</a>
我要把index2.html數(shù)據(jù)傳輸回去,當(dāng)然我的index2打算點(diǎn)擊X的時(shí)候就已經(jīng)把數(shù)據(jù)傳輸回父iframe的框架怎么做,下邊代碼
<script src="jquery.mini.js"></script>
<script src="artDialog.js?skin=default"></script>
<script src="./plugins/iframeTools.js"></script>
<script src="./skins/idialog.css"></script>
<title>jquery的處理</title>
</head>
<body>
<input type="text" id="chushu" value="2222111" />
<script>
var origin = artDialog.open.origin;
var v = origin.document.getElementById('nihao');
v.value = document.getElementById('chushu').value;
</script>
當(dāng)然數(shù)據(jù)不是點(diǎn)擊X按鈕的傳輸可以用自帶的art.dialog.data(‘test', val);這種方法來(lái)傳輸!!事件匆忙寫的比較緊,大家有不懂的找我就可以了!
- artdialog的圖片/標(biāo)題以及關(guān)閉按鈕不顯示的解決方法
- 給artDialog 5.02 增加ajax get功能詳細(xì)介紹
- artDialog 4.1.5 Dreamweaver代碼提示/補(bǔ)全插件 附下載
- artDialog雙擊會(huì)關(guān)閉對(duì)話框的修改過(guò)程分享
- JS中artdialog彈出框控件之提交表單思路詳解
- jQuery validate+artdialog+jquery form實(shí)現(xiàn)彈出表單思路詳解
- artDialog+plupload實(shí)現(xiàn)多文件上傳
- plupload+artdialog實(shí)現(xiàn)多平臺(tái)上傳文件
- jQuery對(duì)話框插件ArtDialog在雙擊遮罩層時(shí)出現(xiàn)關(guān)閉現(xiàn)象的解決方法
- Jquery彈出窗口插件 LeanModal的使用方法
- 使用jQuery插件創(chuàng)建常規(guī)模態(tài)窗口登陸效果
- jQuery插件artDialog.js使用與關(guān)閉方法示例
相關(guān)文章
jQuery.fn和jQuery.prototype區(qū)別介紹
jQuery.fn和jQuery.prototype想必大家對(duì)它并不陌生吧,那么你們知道它們之間的區(qū)別嗎?在本文有個(gè)不錯(cuò)的示例大家可以參考下2013-10-10jquery實(shí)現(xiàn)圖片上傳前本地預(yù)覽
這篇文章主要為大家詳細(xì)介紹了jquery實(shí)現(xiàn)圖片上傳前本地預(yù)覽功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04Jquery獲取第一個(gè)子元素簡(jiǎn)單實(shí)例
下面小編就為大家?guī)?lái)一篇Jquery獲取第一個(gè)子元素簡(jiǎn)單實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-06-06jQuery實(shí)現(xiàn)只允許輸入數(shù)字和小數(shù)點(diǎn)的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)只允許輸入數(shù)字和小數(shù)點(diǎn)的方法,涉及jQuery針對(duì)鍵盤事件的響應(yīng)及字符串操作的相關(guān)技巧,需要的朋友可以參考下2016-03-03jquery實(shí)現(xiàn)兼容IE8的異步上傳文件
這里給大家分享的是使用jQuery插件實(shí)現(xiàn)兼容IE8的異步上傳文件的代碼,效果非常不錯(cuò),有需要的小伙伴可以參考下。2015-06-06自己動(dòng)手制作基于jQuery的Web頁(yè)面加載進(jìn)度條插件
進(jìn)度條插件在GitHub上多種多樣數(shù)量繁多,這總結(jié)出頁(yè)面進(jìn)度條插件的實(shí)現(xiàn)要點(diǎn),來(lái)教大家自己動(dòng)手制作基于jQuery的Web頁(yè)面加載進(jìn)度條插件2016-06-06jQuery實(shí)現(xiàn)的超簡(jiǎn)單輪播圖功能示例【代碼解釋】
這篇文章主要介紹了jQuery實(shí)現(xiàn)的超簡(jiǎn)單輪播圖功能,結(jié)合完整實(shí)例形式分析了基于jQuery實(shí)現(xiàn)的輪播圖相關(guān)功能實(shí)現(xiàn)、樣式設(shè)置與注意事項(xiàng),需要的朋友可以參考下2023-05-05