I have a problem with creating a simple chrome extension.
Following should this program do on the options page:
- User have to enter two values (apikey and apisecure) These values will be saved on local storage.
I want to get these storaged values and print them out on options.html:
<html>
<head>
<title>API-Konfiguration</title>
<script type="text/javascript" src="options.js"></script>
</head>
<body onload="loadOptions()">
<h1>Bitte API-Key und API-Secure hinterlegen:</h1>
<form>
API-Key:<br>
<input type="text" id="v_apikey" name="apikey">
<br>
API-Secure:<br>
<input type="text" id="v_apisecure" name="apisecure">
</form>
<br />
<button onclick="saveOptions()">Speichern</button>
<br />
<button onclick="eraseOptions()">Daten loeschen</button>
</body>
</html>
The options.js contains following:
function loadOptions() {
var apikey = localStorage["v_apikey"];
var apisecure = localStorage["v_apisecure"];
}
function saveOptions() {
var apikey = document.getElementById("v_apikey");
var apisecure = document.getElementById("v_apisecure");
localStorage["v_apikey"] = apikey;
localStorage["v_apisecure"] = apisecure;
}
function eraseOptions() {
localStorage.removeItem("v_apikey");
localStorage.removeItem("v_apisecure");
location.reload();
}
function getItems() {
document.write(localStorage.getItems("v_apikey"));
document.write(localStorage.getItems("v_apisecure"));
}
I don't know how to output the saved values in the input field (If they have already been stored).
Who can help me with this "little" problem?
Thanks in advance!