Skip to content

Instantly share code, notes, and snippets.

@jonasfj
Last active January 26, 2016 06:57
Show Gist options
  • Select an option

  • Save jonasfj/fe6b87f8aa8ce0fcd66e to your computer and use it in GitHub Desktop.

Select an option

Save jonasfj/fe6b87f8aa8ce0fcd66e to your computer and use it in GitHub Desktop.

Simple example to play with cross-site scripting.

<b>Hi, <span id="name"></span>,</b><br>
Enter your deepest secret and I'll remeber it:<br>
<input type="text" id="secret"><button onClick="save()">Save</button>
<script>
// Load name from location.hash
document.getElementById("name").innerHTML = window.location.hash;
// Load existing secret
document.getElementById("secret").value = (localStorage.secret || 42);
// Save secret
function save() {
localStorage.secret = document.getElementById("secret").value;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment