网易云音乐

创作者中心

'); doc.close(); hash = newHash; } catch (e) { setTimeout(function () { setIframe(newHash); }, 10); } }, // Used by Internet Explorer 7 and below to set up an iframe that keeps track // of history changes. setUpIframe = function () { // Don't run until access to the body is allowed. try { iframe = createIframe(); } catch (e) { setTimeout(setUpIframe, 10); return; } // Create a history entry for the initial state. setIframe(hash); var data = hash; setInterval(function () { var curData, curHash; try { curData = iframe.contentWindow.document.body.innerText; if (curData != data) { data = curData; window.location.hash = hash = curData; callback(curData, true); } else { curHash = getHash(); if (curHash != hash) setIframe(curHash); } } catch (e) { } }, 50); }; return { init: function (cb) { // init can only be called once. if (callback) return; callback = cb; // Keep track of the hash value. hash = getHash(); cb(hash, true); if (isHashChangeSupported()) { if (window.addEventListener){ window.addEventListener('hashchange', poll, false); } else if (window.attachEvent){ window.attachEvent('onhashchange', poll); } } else { // Run specific code for Internet Explorer. if (window.ActiveXObject) { if (!documentMode || documentMode < 8) { // Internet Explorer 5.5/6/7 need an iframe for history // support. setUpIframe(); } } else { // Change Opera navigation mode to improve history support. if (history.navigationMode) { history.navigationMode = 'compatible'; } setInterval(poll, 50); } } }, go: function (newHash) { // Cancel if the new hash is the same as the current one, since there // is no cross-browser way to keep track of navigation to the exact // same hash multiple times in a row. A wrapper can handle this by // adding an incrementing counter to the end of the hash. if (newHash == hash) return; if (iframe) { setIframe(newHash); } else { window.location.hash = hash = newHash; callback(newHash, false); } } }; })();var GDispatcher = (function(){ var _lastPage = '', _igReg = /f=(.*?)/, _hReg = /\/?#.*/, _xssReg = /(java|vb)script/,//xss注入 _default = '/discover'; function _isIE10plus(){ var _ua = window.navigator.userAgent; return (/msie\s+(.*?);/i.test(_ua)||/trident\/.+rv:([\d\.]+)/i.test(_ua))&&(parseInt(RegExp.$1)>=10); }; function getDiscoverUrl() { var GDegradeConfig = window.GDegradeConfig || {}; var discoverUrl = GDegradeConfig.degrade && GDegradeConfig.discoverUrl || '/discover'; return encodeURI(discoverUrl); } function _onHashChange(_hash){ var _url, _iframe = document.getElementById('g_iframe'); if(!_hash||_igReg.test(_hash)||_xssReg.test(_hash)){//忽略统计来源的hash _url = _default; }else{ if(_hash.indexOf('/') !== 0) { _hash = '/' + _hash; } _hash = _hash.replace(/\/+/g, '/');//#29664 http://music.163.com/#// 会死循环 var _midx = -1; if((_midx=_hash.indexOf('store/m/'))>=0){ _url = _hash.substring(0, _midx+8)+(_hash.substring(_midx+8).replace('/m/','/#/')); }else{ _url = _hash.replace('/m/','/#/'); // debugger; if(/^\/member\/?(\?[\s\S]*)?$/.test(_url) && typeof vipWebCashierRedirect !== 'undefined' && '' + vipWebCashierRedirect === '1') { // _url = _url.replace('/member','/prime/member'); _url = _url.replace('/member','/discover'); } if (/^\/vip2(\?|\/|$)/.test(_url)) { // _url = _url.replace('/vip2', '/prime/member'); _url = _url.replace('/vip2','/discover'); } } } if(_url === '/discover') { _url = getDiscoverUrl(); } if(!_url.match(/^https?:/)){ _url = location.protocol+'//'+location.hostname+_url; } //针对ie10+ location.replace的bug做特殊处理 if(_isIE10plus()){ if(_lastPage.replace(_hReg,'')==_url.replace(_hReg,'')){//只是hash的改变 _iframe.contentWindow.location.replace(_url); } else{ _iframe.parentNode.removeChild(_iframe); _iframe = document.createElement('iframe'); _iframe.id = 'g_iframe'; _iframe.src = 'about:blank'; _iframe.className = 'g-iframe'; _iframe.setAttribute('allowfullscreen', true); document.body.insertAdjacentElement('afterBegin',_iframe); _iframe.contentWindow.location.href = _url; } }else{ _iframe.contentWindow.location.replace(_url); } _lastPage = _url; if(typeof window.onHashChange=='function'){ window.onHashChange(_hash); } }; Hash.init(_onHashChange); return { dispatch:function(_url,_replace){ var _ph = GUtil.getPathAndHash(_url); if(!_ph) return; if(_replace){ location.replace(GUtil.getBase()+'#'+_ph); }else{ location.hash = _ph; } }, refreshIFrame:function(_url){ _onHashChange(_url); } }; })();

00:00 / 00:00
0
评论 110/120
回复 110/120
回复 110/120
发送110/120
评论 110/120
发送 110/120
140
转发 取消
140/140
分享 取消
140
分享 取消