위챗 브라우저의 대부분 브라우저의 반환 문제

7719 단어 위챗
<script type="text/javascript">
			XBack = {};

			(function(XBack) {
				XBack.STATE = 'x - back';
				XBack.element;

				XBack.onPopState = function(event) {
					event.state === XBack.STATE && XBack.fire();
					XBack.record(XBack.STATE); // ,push   
				};

				XBack.record = function(state) {
					history.pushState(state, null, location.href);
				};

				XBack.fire = function() {
					var event = document.createEvent('Events');
					event.initEvent(XBack.STATE, false, false);
					XBack.element.dispatchEvent(event);
				};

				XBack.listen = function(listener) {
					XBack.element.addEventListener(XBack.STATE, listener, false);
				};

				XBack.init = function() {
					XBack.element = document.createElement('span');
					window.addEventListener('popstate', XBack.onPopState);
					XBack.record(XBack.STATE);
				};

			})(XBack); //  js   

			XBack.init();
			XBack.listen(function() {});
		</script>

좋은 웹페이지 즐겨찾기