Skip to content

Instantly share code, notes, and snippets.

@stolksdorf
Last active August 22, 2021 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stolksdorf/258774eaa531b52aae4b269da1009b0c to your computer and use it in GitHub Desktop.
Save stolksdorf/258774eaa531b52aae4b269da1009b0c to your computer and use it in GitHub Desktop.
js pad - a bookmarklet for js fiddling

js_pad

a micro javascript sandbox to play around in

Make a new bookmark, then copy and paste this as the URL:

data:text/html,<html contenteditable onkeyup="try{this.style.color='rgb(240,239,208)';console.clear();eval(this.innerText);}catch(err){this.style.color='rgb(223,175,143)';console.log(err);}"><title>js_pad</title><style>html{background:rgb(63,63,63);color:rgb(240,239,208);font-size:1.5em;font-family:Monospace}</style></html>

how it works

uses contenteditable to make the root html element edittable. On every keypress it evals the page's content. Changes the text color if it's valid code or not. Open dev tools and use console.log to see the results for your code.

  • @mentions, #refs, links, formatting, and tags supported
  • list syntax required (any unordered or ordered list supported)
  • this is a complete item
  • this is an incomplete item

readable code

data:text/html,<html contenteditable onkeyup="try{
		this.style.color='rgb(240,239,208)';
		console.clear();
		eval(this.innerText);
	}catch(err){
		this.style.color='rgb(223,175,143)';
		console.log(err);
	}">
	<title>js_pad</title>
	<style>
		html{
			background:rgb(63,63,63);
			color:rgb(240,239,208);
			font-size:1.5em;
			font-family:Monospace
		}
	</style>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment