Created
September 20, 2011 18:31
-
-
Save felquis/1229897 to your computer and use it in GitHub Desktop.
Este é o primeiro exemplo do mini-curso sobre WebStorage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="pt-br" dir="ltr"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/hmtl; charset=uft8" /> | |
<title>Exemplo 1 sessionStorage html5</title> | |
<style> | |
label{ | |
display:block; | |
} | |
</style> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> | |
<script type="text/javascript" > | |
$(document).ready(function(){ | |
// #1 | |
var session = sessionStorage | |
, sessionCampo = session.getItem('campo') | |
, $input = $('#text') | |
, valor = $input.val(); | |
// #2 | |
$input.val(sessionCampo); | |
// #3 | |
setInterval(function(){ | |
valor = $input.val(); | |
session.setItem('campo', valor); | |
console.log(session); | |
}, 500); | |
}); | |
</script> | |
</head> | |
<body> | |
<h2>Exemplo 1</h2> | |
Este exemplo usa o sessionStorage para gravar o que você esta digitando,<br /> | |
1 - digite algo<br /> | |
2 - atualize o browser<br /> | |
3 - feche o browser diretamente pelo (x) do windows e abra-o novamente, PROCURE RESTAURAR SESSÃO<br /> | |
<hr /> | |
<label for="text">Escreva algo, </label> | |
<textarea maxlength="140" id="text" placeholder="qualquer coisa, e depois atualize."></textarea> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment