Skip to content

Commit

Permalink
修正落网电台由于多次加载从而造成样式失效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ywzhaiqi committed Aug 17, 2015
1 parent 29be605 commit b719296
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions SimpleMusicPlayer/SimpleMusicPlayer.uc.js
Original file line number Diff line number Diff line change
Expand Up @@ -864,12 +864,13 @@
// 先设为空白,加快速度?
this.setIframeSrc("about:blank", iframe);

if (siteIndex == undefined) {
if (siteIndex === undefined) {
siteIndex = this.curSiteIndex;
}

var curSite = Sites[siteIndex],
var curSite = Sites[this.curSiteIndex],
url = curSite.url;
this.curSite = curSite;

// 打开新窗口的
if (curSite.isWindow) {
Expand Down Expand Up @@ -921,7 +922,7 @@
iframe.setAttribute("style", iStyle);

// 强制链接在 iframe 里打开
var onclick = curSite.openLinkInsided == true ?
var onclick = curSite.openLinkInsided ?
"SimpleMusicPlayer.openLinkInIframe(event);" : "";
iframe.setAttribute("onclick", onclick)

Expand All @@ -932,18 +933,8 @@

this.setIframeSrc(url, iframe);

var onload = function(event){
var doc = event.originalTarget;
if (doc.location.href == "about:blank") return;

iframe.removeEventListener("DOMContentLoaded", onload, false);

// 添加样式
var style = doc.createElement("style");
style.textContent = curSite.css;
doc.head.appendChild(style);
};
iframe.addEventListener("DOMContentLoaded", onload, false);
iframe.removeEventListener("DOMContentLoaded", this.iframeOnload, false);
iframe.addEventListener("DOMContentLoaded", this.iframeOnload, false);

openPopup();

Expand All @@ -952,6 +943,17 @@
UAManager.revert();
}
},
iframeOnload: function(event) { // this 非 SimpleMusicPlayer
var doc = event.originalTarget;
if (doc.location.href == "about:blank") return;

var curSite = SimpleMusicPlayer.curSite;

// 添加样式
var style = doc.createElement("style");
style.textContent = curSite.css;
doc.head.appendChild(style);
},
close: function() {
if (this.newWindow) {
try { // 可能是 dead object
Expand Down

0 comments on commit b719296

Please sign in to comment.