導航:首頁 > 編程語言 > js打開手機相冊

js打開手機相冊

發布時間:2024-05-08 14:39:49

Ⅰ 誰幫我寫一下js, 點擊展開,再點擊關閉。

可以參考下面的代碼

var tag="off";//記錄開關狀zd態

function test(obj){

//打開

if(tag=="off"){

obj.style.height="150px";//展開的高度版

tag="on";//開關設為打開狀專態

}else{

obj.style.height="0px";//高度設權為0

obj.style.display="none";//隱藏

tag="off";//開關設為關屬閉

}

}

(1)js打開手機相冊擴展閱讀:

javaScript參考函數

getHours() 返回小時數(0-23)

getMinutes() 返回分鍾(0-59)

getSeconds() 返回秒數(0-59)

getMilliseconds() 返回毫秒(0-999)

getUTCDate() 依據國際時間來失掉日(1-31)

getUTCMinutes() 根據邦際光陰來往歸分鍾(0-59)

getUTCSeconds() 依據國際時間來返回秒(0-59)

getUTCMilliseconds()依據國際時間來返回毫秒(0-999)

Ⅱ 怎麼用html5或js調用手機的攝像頭拍照上傳以及調用手機相冊選取照片

1、實現頭來的方法代碼。

注意事項:

JavaScript是一種網路腳本語言,在web應用開發中得到了廣泛的應用,它經常被用來為網頁添加各種動態功能,為用戶提供更加流暢美觀的瀏覽效果,通常JavaScript腳本被嵌入到HTML中來實現自己的功能。

Ⅲ html5或者JS怎樣調用手機攝像頭或者相冊

你給的網頁用的是 <input accept="image/*" type="file">,在IOS端點擊時會提示選擇圖片或相機,安卓端要看瀏覽器對這兩內個屬容性的優化,部分瀏覽器會直接跳轉到資源管理器,優化做得好的可以直接提示選擇相冊或相機。

Ⅳ javascript點擊查看圖片,彈框顯示圖片,怎麼用js怎麼實現

最好用插件,去layer官網有專門的點擊圖片,彈出瀏覽還支持多個圖片。

先去官網下載版layer包,你的權網頁引用layer的js文件

地址:網頁鏈接點擊相冊層

然後js代碼:

//調用示例

layer.ready(function(){ //為了layer.ext.js載入完畢再執行

var ps=$("#psize").val();

layer.photos({

photos: '#layer-photos-demo'

,shift: ps //0-6的選擇,指定彈出圖片動畫類型,默認隨機

});

});

html代碼:

<div id="layer-photos-demo" class="layer-photos-demo" >

<img layer-pid="圖片id,可以不寫" layer-src="縮略圖片地址" src="圖片地址" alt="" style="height: 140px;width: 120px;border:1px solid #bbb;">

</div>

Ⅳ 當點擊帶+的圖片時,彈出手機相冊,可以選擇手機相冊內的圖片上傳,代碼如何寫怎麼實現

首先需要引用 js 和css

<!--上傳控制項-->
2<scriptsrc="query.form.min.js"></script>
3<linkhref="Img_List.css"rel="stylesheet"/>
4<scriptsrc="Img_List.js"></script>

Img_List.js 如下:

///<referencepath="../../script/jquery-1.8.0.min.js"/>
//顯示
functionimgshow(obj){
//$(obj).find("a").show();
}

//隱藏
functionimghide(obj){
//$(obj).find("a").hide();
}

//上傳
functionupload(){
$("#FileLoad").click();
}

//刪除
functionimgdel(listId,FileId,hfId){

$.post("/CommonMole/ashx/public.ashx?action=DelMessageImg&Files="+$("#"+hfId).val(),function(result){
if(result!="ok")
$.messager.alert("消息提示","刪除失敗!");
});
varhtml="<li><imgsrc="/Themes/Images/jia.jpg"style="height:80px;width:80px;"/><inputtype="file"id=""+FileId+""class="input"onchange="ImgUpload('"+FileId+"','"+hfId+"','"+listId+"');"name=""+FileId+""/></li>"
$("#"+listId).html(html);
}

//添加成功
functionimgaddhtml(data,code,listId,fileId,hfId){
varlist=data.split(',');
varhtml="<lionmouseover="imgshow(this)"onmouseout="imghide(this);">";
html+="<astyle="height:80px;width:80px;"href=""+list[0]+""target="_blank"><imgsrc=""+list[0]+""imgs=""+list[0]+""code=""+code+""/></a><spanonclick="imgdel('"+listId+"','"+fileId+"','"+hfId+"')"></span></li>";
$("#"+listId).html(html);
}

//圖片文件上傳
//uppath上傳空間id
//上傳成功存放的圖片路徑的隱藏域id
//listId顯示圖片的區域id
functionImgUpload(uppath,hndimg,listId){
varsendUrl="/CommonMole/ashx/Upload_Ajax.ashx?action=SingleFile&IsThumbnail=1&UpFilePath="+uppath;
//開始提交
$("#form1").ajaxSubmit({
beforeSubmit:function(formData,jqForm,options){
//alert(1);
},
success:function(data,textStatus){
varlist=$("#"+hndimg).val();
$("#"+hndimg).val(data.msgbox);
imgaddhtml(data.msgbox,0,listId,uppath,hndimg);
},
error:function(data,status,e){
alert("上傳失敗!");
},
url:sendUrl,
type:"post",
dataType:"json",
timeout:600000
});
};
Img_List.css如下:
.img_list{margin:0px;padding:0px;overflow:hidden;}
.img_listul,.img_listulli{margin:0px;padding:0px;}
.img_listulli{float:left;list-style:none;position:relative;margin:5px0px0px5px;}
.img_listullispan
{position:absolute;top:3px;right:3px;width:16px;height:16px;opacity:0.6;filter:alpha(opacity=60);margin:0002px;
vertical-align:top;background:url('/Themes/Images/panel_tools.png')no-repeat-16px0px;}
.img_listulliimg{width:80px;height:80px;cursor:pointer;position:relative;z-index:0;}
.img_listulli.input{width:80px;height:80px;cursor:pointer;position:relative;left:-100px;vertical-align:top;margin:0px;padding:0px;opacity:0;filter:alpha(opacity=0);}

panel_tools.png 如下:

#region上傳單文件處理===================================
46privatevoidSingleFile(HttpContextcontext)
47{
48
49string_refilepath=context.Request.QueryString["ReFilePath"];//取得返回的對象名稱
50string_upfilepath=context.Request.QueryString["UpFilePath"];//取得上傳的對象名稱
51string_delfile=context.Request.QueryString[_refilepath];
52HttpPostedFile_upfile=null;
53try
54{
55_upfile=context.Request.Files[_upfilepath];
56}
57catch(Exceptione)
58{
59context.Response.Write("{"msg":"0","msgbox":"上傳文件過大!"}");
60context.Response.End();
61}
62bool_iswater=false;//默認不打水印
63bool_isthumbnail=false;//默認不生成縮略圖
64bool_isimage=false;
65
66if(context.Request.QueryString["IsWater"]=="1")
67_iswater=true;
68if(context.Request.QueryString["IsThumbnail"]=="1")
69_isthumbnail=true;
70if(context.Request.QueryString["IsImage"]=="1")
71_isimage=true;
72
73if(_upfile==null)
74{
75context.Response.Write("{"msg":"0","msgbox":"請選擇要上傳文件!"}");
76return;
77}
78UpLoapFiles=newUpLoad();
79stringmsg=upFiles.fileSaveAs(_upfile,_isthumbnail,_iswater,_isimage);
80//刪除已存在的舊文件
81Utils.DeleteUpFile(_delfile);
82//返回成功信息
83context.Response.Write(msg);
84
85context.Response.End();
86}
87#endregion

101publicstringfileSaveAs(HttpPostedFilepostedFile,boolisThumbnail,boolisWater,bool_isImage,bool_isReOriginal)
102{
103try
104{
105stringfileExt=Utils.GetFileExt(postedFile.FileName);//文件擴展名,不含「.」
106stringoriginalFileName=postedFile.FileName.Substring(postedFile.FileName.LastIndexOf(@"")+1);//取得文件原名
107stringfileName=Utils.GetRamCode()+"."+fileExt;//隨機文件名
108stringdirPath=GetUpLoadPath();//上傳目錄相對路徑
109
110//檢查文件擴展名是否合法
111if(!CheckFileExt(fileExt))
112{
113return"{"msg":"0","msgbox":"不允許上傳"+fileExt+"類型的文件!"}";
114}
115//檢查是否必須上傳圖片
116if(_isImage&&!IsImage(fileExt))
117{
118return"{"msg":"0","msgbox":"對不起,僅允許上傳圖片文件!"}";
119}
120//檢查文件大小是否合法
121if(!CheckFileSize(fileExt,postedFile.ContentLength))
122{
123return"{"msg":"0","msgbox":"文件超過限制的大小啦!"}";
124}
125//獲得要保存的文件路徑
126stringserverFileName=dirPath+fileName;
=dirPath+"small_"+fileName;
128stringreturnFileName=serverFileName;
129//物理完整路徑
130stringtoFileFullPath=Utils.GetMapPath(dirPath);
131//檢查有該路徑是否就創建
132if(!Directory.Exists(toFileFullPath))
133{
134Directory.CreateDirectory(toFileFullPath);
135}
136//保存文件
137postedFile.SaveAs(toFileFullPath+fileName);
138//如果是圖片,檢查圖片尺寸是否超出限制
139if(IsImage(fileExt))
140{
141Thumbnail.MakeThumbnailImage(toFileFullPath+fileName,toFileFullPath+fileName,3000,3000);
142}
143//是否生成縮略圖
144if(IsImage(fileExt)&&isThumbnail)
145{
146Thumbnail.MakeThumbnailImage(toFileFullPath+fileName,toFileFullPath+"small_"+fileName,150,150,"R");
147//returnFileName+=","+serverThumbnailFileName;//返回縮略圖,以逗號分隔開
148}
149
166/
171return"{"msg":"1","msgbox":""+returnFileName+""}";
172}
173catch
174{
175return"{"msg":"0","msgbox":"上傳過程中發生意外錯誤!"}";
176}
177}

Ⅵ html5 如何調用手機相冊

需要載入cordova.js
方法:

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
pictureSource = navigator.camera.PictureSourceType;
destinationType = navigator.camera.DestinationType;
}
//相冊
function fromCamera()
{
var source = pictureSource.PHOTOLIBRARY;
navigator.camera.getPicture(function (imageData) {
setimg(imageData);
}, function (message) {
if (source == pictureSource.CAMERA)
alert('載入照相機出錯!' + message);
else
alert('載入相冊出錯!' + message);
}, {
quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: source
});
}
//拍照
function EditImgPz()
{
navigator.camera.getPicture(function (imageData) {
setimg(imageData);
}, function (message) {
alert(message);
}, {
quality: 50,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: true
});
}

閱讀全文

與js打開手機相冊相關的資料

熱點內容
java大數據技術有哪些 瀏覽:718
可信編程是什麼 瀏覽:824
大數據產生三個主要推手 瀏覽:385
js數字正則表達式 瀏覽:865
物流做數據的是什麼崗位 瀏覽:80
jsp傳到mysql亂碼 瀏覽:584
有什麼免費的鋼琴陪練app 瀏覽:720
品牌知名度的數據信息從哪裡找 瀏覽:206
網路技術簡介 瀏覽:96
數控銑床如何使用軟體編程 瀏覽:875
遠程桌面無法傳輸文件 瀏覽:953
ie8怎樣升級到ie11 瀏覽:397
榆林市榆陽區有哪些編程課 瀏覽:246
輕松備份專業版教程 瀏覽:658
移動網路2g怎麼改成4g 瀏覽:634
linux設置字體大小 瀏覽:329
安全牛的linux 瀏覽:672
wps會緩存excel文件么 瀏覽:592
app開發phpjava哪個更好 瀏覽:53
app有十萬用戶是什麼概念 瀏覽:285

友情鏈接