-4
I was looking for more knowledge about cookies on youtube and only found video in English, but what’s the big deal? I don’t speak English! However I was able to understand that cookies work in this way stored, read and sometimes deleted.
What am I getting at? Well... I want to put cookies in 2 scripts, but so far can not. I had asked here on the forum how to put cookies in this script
<a id="id1" href="https://br.answers.yahoo.com" onclick="myFunction(event)" target="_blank">Clique Aqui</a> <br/><br/>
<script language="javascript">
function myFunction(s) {
var id = s.target.id;
document.getElementById(id).style.color = "green";
setTimeout(function(){
document.getElementById(id).style.color = "blue";
}, 10000);
}
</script>
Then I got this reply:
If you want it to continue indefinitely until you delete it, you can do this with Html5, or if you want it to forget the data when closing the browser as well.
INDEFINIDAMENTE: // Armazenar
localStorage.setItem("lastname", "Smith");
// Receber
var lastname = localStorage.getItem("lastname");
// Remover
localStorage.removeItem("lastname");
TEMPORARIAMENTE // Armazenar
sessionStorage.setItem("lastname", "Smith");
// Receber
var lastname = sessionStorage.getItem("lastname");
// Remover
sessionStorage.removeItem("lastname");
But I do not understand how to insert, has how to help me?
Thanks man, Ta very detailed! :-)
– Márcio Sebastião