Created
December 19, 2023 07:37
-
-
Save azophy/ad8e344cfd7f188701eb5769018c352b to your computer and use it in GitHub Desktop.
PoC sharing localstorage antar iframe
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
<!-- MVP.css quickstart template: https://github.com/andybrewer/mvp/ --> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<link rel="icon" href="https://via.placeholder.com/70x70"> | |
<link rel="stylesheet" href="https://unpkg.com/mvp.css"> | |
<meta charset="utf-8"> | |
<meta name="description" content="My description"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>My title</title> | |
</head> | |
<body> | |
<header> | |
<h1>Embed example</h1> | |
<p>isi storage: <strong id="isi"></strong></p> | |
<br> | |
<p> | |
<button type="buton" onclick="updateShow()">cek isi</button> | |
</p> | |
</header> | |
<main> | |
</main> | |
<script> | |
function updateShow() { | |
document.getElementById('isi').innerHTML = localStorage.getItem('wowo') | |
} | |
window.addEventListener('storage', function(event) { | |
updateShow(); | |
}); | |
</script> | |
</body> | |
</html> |
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
<!-- MVP.css quickstart template: https://github.com/andybrewer/mvp/ --> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<link rel="icon" href="https://via.placeholder.com/70x70"> | |
<link rel="stylesheet" href="https://unpkg.com/mvp.css"> | |
<meta charset="utf-8"> | |
<meta name="description" content="My description"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>My title</title> | |
</head> | |
<body> | |
<header> | |
<h1>demo ganti value iframe</h1> | |
<p>ganti isi storage: <input type="text" id="ganti" onchange="updateStorage()"></p> | |
<br> | |
</header> | |
<main> | |
<section> | |
<iframe style="width:800px;height:400px" src="./embed.html" frameborder="1"></iframe> | |
</section> | |
</main> | |
<script> | |
function updateStorage() { | |
localStorage.setItem('wowo', document.getElementById('ganti').value); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment