Parašė blynaas· 2012 Gru. 8 18:12:55
#1
Sveiki,
niekaip neiseina padaryti kad perkrovus/ isjungus ir per nauja ijungus puslapi rodytu ta pacia spalva kuria nustaciau pries isjungdamas/perkraudamas. Reikia naudotis Local storage funkcijomis, nelabai as istikro ten suprantu, pagal pavyzdzius dariau, nesigauna. Gal kazko truksta, ar ne taip ka rasau? Gal kas nors galite padeti?
pilnas kodas:
<!DOCTYPE
html>
<html>
<head>
<meta name="viewport" content="width=device-width"/>
<title> Data assignment nr.1 </title>
<style>
</style>
</head>
<body>
<h1> Mobile applications </h1>
<hr> This is a mandatory assignment for <i>Data</i> lecture <hr>
<script>
spalva1 = "blue";
spalva2 = "red"
spalva3 = "yellow"
spalva4 = "grey"
spalva5 = "purple"
spalva6 = "orange"
function pakeisti(spalva)
{
document.bgColor = spalva;
window.localStorage.setItem("bckground", document.bgColor);
var storedValue = window.localStorage.getItem("bckground");
if (storedValue!=null){
value = parseInt(storedValue);
document.bgColor;
}}
</script>
<button type="button" onclick="pakeisti(spalva1)">Blue</button>
<button type="button" onclick="pakeisti(spalva2)">Red</button>
<button type="button" onclick="pakeisti(spalva3)">Yellow</button>
<button type="button" onclick="pakeisti(spalva4)">Grey</button>
<button type="button" onclick="pakeisti(spalva5)">Purple</button>
<button type="button" onclick="pakeisti(spalva6)">Orange</button>
</body>
</html>