导航:首页 > 编程语言 > 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打开手机相册相关的资料

热点内容
为啥qq群文件下载不了 浏览:1
note3开机密码设置 浏览:64
excel表文件怎么按照日期排序 浏览:745
源网站招聘 浏览:729
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

友情链接