Safari WebApp 模拟 原声APP禁止打开新窗口JS代码


        if(("standalone" in window.navigator) && window.navigator.standalone) {
		var noddy, remotes = false;
		document.addEventListener('click', function(event) {
			noddy = event.target;
			while(noddy.nodeName !== "A" && noddy.nodeName !== "HTML") {
				noddy = noddy.parentNode;
			}
			if('href' in noddy && noddy.href.indexOf('http') !== -1 && (noddy.href.indexOf(document.location.host) !== -1 || remotes)) {
				event.preventDefault();
				document.location.href = noddy.href;
			}
		},false);
	}

posted @ 2016-04-27 15:51  陈朔  阅读(451)  评论(0编辑  收藏  举报