我开发了一个带登陆页面的比特币钱包应用,

当我单击Balance按钮时,我会在控制台中获得JSON,

显示JSON的相应代码是,
$("#balance").click(function () {
clearInterval(transactionsIntervalId);
clearInterval(balanceIntervalId);
balanceIntervalId = setInterval(function () {
var address = $('#address').find(":selected").text();
var explorers = require('bitcore-explorers');
var client = new explorers.Insight('testnet');
client.address(address, function (err, info) {
if (err) throw err;
info.wallet = info.address.toString();
setConsoleData('info:', info);
});
}, 1000);
});我得把它改成,
$("#balance").click(function () {
clearInterval(transactionsIntervalId);
clearInterval(balanceIntervalId);
var address = $('#address').find(":selected").text();
var explorers = require('bitcore-explorers');
var client = new explorers.Insight('testnet');
window.open('balance.html#' + address);
});因此,它基本上是在新选项卡中打开balance.html页面。下面提供了balance.html,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Balance</title>
<!-- Bootstrap Core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Theme CSS -->
<link href="css/main.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<!-- to clear the saved address use: localStorage.clear(); -->
<body id="page-top" class="index">
The current balance
</body>
</html>在前面提供的JSON中有balance和wallet信息,我想在balance.html页面中显示它们。如何做到这一点?如果需要,我可以提供更多信息。
发布于 2017-07-18 09:27:15
$("#balance").click(function () {
clearInterval(transactionsIntervalId);
clearInterval(balanceIntervalId);
balanceIntervalId = setInterval(function () {
var address = $('#address').find(":selected").text();
var explorers = require('bitcore-explorers');
var client = new explorers.Insight('testnet');
client.address(address, function (err, info) {
if (err) throw err;
info.wallet = info.address.toString();
window.open('balance.html?balance ='+ info.balance +'&wallet ='+ info.wallet);
});
}, 1000);
});balance.html
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Balance</title>
<!-- Bootstrap Core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Theme CSS -->
<link href="css/main.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<!-- to clear the saved address use: localStorage.clear(); -->
<body id="page-top" class="index">
<div id="balance"></div>
<div id="wallet"></div>
</body>
<script>
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null)
return unescape(r[2]);
return null;
}
balance = getQueryString('balance');
wallet = getQueryString('wallet');
document.getElementById('balance').innerHTML = balance;
document.getElementById('wallet').innerHTML = wallet;
</script>发布于 2017-07-17 17:10:50
我想您想要将数据从当前页面转移到新打开的页面并显示它?
https://stackoverflow.com/questions/45139959
复制相似问题