Some answers to my own question :)
You can quickly run HTML in the browser without creating a HTML file:
Enter this in the address bar:
data:text/html,<h1>Hello, world!</h1>
(This won't work in IE)
You can make a page's CSS editable in the browser without using JS :
<!DOCTYPE html>
<html>
<body>
<style style="display:block" contentEditable>
body { color: blue }
</style>
</body>
</html>
(This also won't work in IE)
You can have the browser parse a URL for you like this:
var a = document.createElement('a');
a.href = url;
// any property of window.location works here:
document.write('The hostname of ' + url + ' is ' + a.hostname);
(Works in all major browsers)
You can invalidate a URL in the browser's cache by sending a PUT method xmlhttprequest to it:
var xhr = window.XMLHttpRequest ?
new XMLHttpRequest() :
new ActiveXObject('Microsoft.XMLHTTP');
xhr.open('PUT', url);
xhr.send(null);
(Works in all major browsers)
You can put multiple statements in anif
block without using curly bracketslike this:
if (confirm("Do you wish to see two alerts?"))
alert(1), alert(2);
(Works in all major browsers)