[英]How to pass the javascript variable value from one html page to the another html page?
[英]How to pass value from one html page to another in JavaScript?
我知道這個問題很多次,但我的問題是不同的。
我有3個html頁面,如apply.html
, personal_info.html
, resume info.html
。
在apply.html頁面中: -
我使用一個LinkedIn按鈕進行LinkedIn登錄。 當用戶點擊該按鈕並填寫登錄信息時,它從LinkedIn獲取用戶數據。 並在同一頁面上顯示(apply.html)。
在personal_info.html中: -
我需要在我們從LinkdIn獲取的相應TextField
顯示這些個人信息。
在Resume_info.html中: -
在這里,我需要顯示我們使用LinkedIn在apply.html頁面上獲取的職業信息。
我不明白怎么做? 我是Html,JavaScript
新手。
這是我的代碼供您參考。
Apply.html我在哪里獲取LinkedIn日期
<html>
<head>
<script type="text/javascript">
function loadData() {
IN.API.Profile("me")
.fields(["id", "firstName", "lastName", "pictureUrl","headline","industry","location:(name)","positions:(title)","emailAddress"])
.result(function(result) {
profile = result.values[0];
profHTML = "<p><a href=\"" + profile.publicProfileUrl + "\">";
profHTML += "<img class=img_border align=\"left\" src=\"" + profile.pictureUrl + "\"></a>";
profHTML += "<a href=\"" + profile.publicProfileUrl + "\">";
profHTML += "<h2 class=myname>" + profile.firstName + " " + profile.lastName + "</a> </h2>";
profHTML += "<span class=myheadline>" + profile.headline + "</span>";
profHTML += "<h3>" + profile.industry + "</h3>";
profHTML += "<h3>" + profile.location.name + "</h3>";
profHTML += "<h3>" + profile.positions.values[0].title + "</h3>";
profHTML += "<h3>" + profile.positions.values[1].title + "</h3>";
profHTML += "<h3>" + profile.emailAddress + "</h3>";
$("#profiles").html(profHTML);
});
}
</script>
</head>
<body>
<script type="IN/Login" data-onAuth="loadData"></script>
<div id="profiles"></div>
<div id="profiles1"></div>
</body>
personal_Info.html我需要顯示LinkedIn數據。
<body>
<div id="container">
<section>
<div class="results">
<div class="results-head">
Personal Info
<div class="pagecount">1/6</div>
</div>
<div class="job-des">
<div class="row">
<input name="textfield2" type="text" id="textfield1" value="First Name" class="input-field" onblur="if (this.value == '')">
</div>
<div class="row">
<input name="textfield" type="text" id="textfield2" value="Last Name" class="input-field">
</div>
<div class="row">
<input name="textfield" type="text" id="textfield3" value="Street Address" class="input-field">
</div>
<div class="row">
<input name="textfield" type="text" id="textfield4" value="City" class="input-field">
</div>
<div class="row">
<select name="select2" id="select2" class="input_list2">
<option value=""> Country </option>
</select>
</div>
<div class="row">
<select name="select2" id="select3" class="input_list2">
<option>State</option>
</select>
</div>
<div class="row">
<select name="select2" id="select4" class="input_list2">
<option>Region</option>
</select>
</div>
<div class="row">
<input name="textfield" type="text" id="textfield5" value="Zip/Postal Code" class="input-field">
</div>
<div class="row">
<input name="textfield" type="text" id="textfield6" value="Email Address" class="input-field">
</div>
<div class="row">
<input name="" type="checkbox" value="" checked align="bottom">
Authorization to work in U.S.
</div>
</div>
</div>
<div class="input-btn-panel">
<div class="input-btn-wrap"><input type="submit" name="button" id="button" value="Next" class="blue-btn" onClick="updateTxt()"></div>
<div id="profiles"></div>
</div>
</body>
請給我一些提示。 我不明白怎么做?
您可以使用HTML5本地存儲。 它允許您告訴瀏覽器將數據保存在用戶的計算機上。 (還有會話存儲 ,僅對當前會話有效。)
保存(在Apply.html中)
IN.API.Profile("me")
.fields(["id", "firstName", "lastName", "pictureUrl","headline","industry","location:(name)","positions:(title)","emailAddress"])
.result(function(result) {
profile = result.values[0];
// save all keys to local storage
for (f in profile) localStorage[f] = fields[f];
// more stuff ...
});
檢索(在personal_Info.html中)
// retrieve first name from local storage
var firstName = localStorage["firstName"];
if (firstName !== undefined) {
$("#textfield1").attr(value, firstName);
}
那么你可以使用HTML5會話存儲。 檢查此鏈接 。
只需深入研究HTML5會話存儲,你會發現很多例子。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.