generalizing the JS dom manipulations not to depend on #page