intelligently hide back and forward buttons