Fixed a bug where the onpage event was called twice