Skip to content

Instantly share code, notes, and snippets.

@leafsummer
Last active April 21, 2024 20:06
Show Gist options
  • Save leafsummer/22ef8cc5f3d4acf1930478c23351d2ec to your computer and use it in GitHub Desktop.
Save leafsummer/22ef8cc5f3d4acf1930478c23351d2ec to your computer and use it in GitHub Desktop.
gravityscript using document

Javascript to make objects on your webpage obey gravity, by Joseph Paul Cohen

GravityScript, By Joseph Paul Cohen

This is a general version of the Google Gravity code written by Mr. Doob as a Chrome Experiment.

Just Include this file somewhere inside the body or head tag

<script src="http://gravityscript.googlecode.com/svn/trunk/gravityscript.js"></script>

Or run the bookmarklet by setting this as the link in a bookmark and clicking it while on ANY page. NOTE:NOTE:NOTE some browsers will remove the javascript: when you paste this string in the url bar. You can just add it back in after you paste it.

javascript:var script = document.createElement("script"); script.src="http://gravityscript.googlecode.com/svn/trunk/gravityscript.js"; document.body.appendChild(script);void(0);

If you include this script or eval this javascript after the body tag has loaded it will do it's awesome thing.

The standard version waits for a user to move their mouse. This version starts without the mouse moving:

<script src="http://gravityscript.googlecode.com/svn/trunk/gravityscript-autorun.js"></script>

or a shortened version

<script src="http://tinyurl.com/grav-js"></script>

http://gravityscript.googlecode.com/svn/trunk/gravityscript.png' />

-By Joseph Paul Cohen and others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment