gpt4 book ai didi

javascript - 将 imageURI 传递到另一个 html 页面

转载 作者:行者123 更新时间:2023-12-03 10:17:09 25 4
gpt4 key购买 nike

我使用 PhoneGap 创建移动应用程序,可以从相册中选择图像,然后我想传递该图像并显示在另一个 html 页面中。有人知道该怎么做吗?这是我的代码

选择图像.html

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">

var pictureSource;
var destinationType;

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady(){
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
}

function onPhotoURISuccess(imageURI){

window.location.href = "review.html";

var image = document.getElementById('image');
image.style.display = 'block';
image.src = imageURI;
}

function getPhoto(source){
navigator.camera.getPicture(onPhotoURISuccess, onFail, {quality: 50,
destinationType: destinationType.FILE_URI, sourceType: source});
}

function onFail(msg){
alert('Failed because: ' + msg);
}

</script>
</head>
<body>

<button onclick="getPhoto(pictureSource.SAVEDPHOTOALBUM);">From Photo Album</button>
<!--<img style="display:none;width:60px;height:60px;" id="image" src="" />-->

</body>
</html>

评论.html

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Review</title>
</head>
<body>
<br>

<img style="display:none;width:60px;height:60px;" id="image" src="" />


<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script src="js/jquery-2.0.3.min.js"></script>
</body>
</html>

最佳答案

您可以使用 html5 本地存储。

localStorage.seItem('url','your image path');

在下一页上访问它

var myUrl = localStorage.url

关于javascript - 将 imageURI 传递到另一个 html 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29813776/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com