Skip to content

Commit 2a23cb6

Browse files
committed
Fixed framesets
1 parent 331556f commit 2a23cb6

2 files changed

Lines changed: 25 additions & 23 deletions

File tree

htmlpreview.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,8 @@ var HTMLPreview = {
1313
},
1414

1515
replaceAssets: function() {
16-
var link, script, frame, a, i, href, src;
17-
link = document.getElementsByTagName('link');
18-
for(i = 0; i < link.length; ++i) {
19-
if(link[i].rel
20-
&& link[i].rel.toLowerCase() == 'stylesheet'
21-
&& link[i].href) {
22-
href = link[i].href; //Get absolute URL
23-
if(href.indexOf('//raw.github.com') > 0 || href.indexOf('//bitbucket.org') > 0) { //Check if it's from raw.github.com or bitbucket.org
24-
HTMLPreview.send(href, 'loadCSS'); //Then load it using YQL
25-
}
26-
}
27-
}
28-
script = document.getElementsByTagName('script');
29-
for(i = 0; i < script.length; ++i) {
30-
if(script[i].src) {
31-
src = script[i].src; //Get absolute URL
32-
if(src.indexOf('//raw.github.com') > 0 || src.indexOf('//bitbucket.org') > 0) { //Check if it's from raw.github.com or bitbucket.org
33-
HTMLPreview.send(src, 'loadJS'); //Then load it using YQL
34-
}
35-
}
36-
}
37-
frame = [].concat.apply([].concat.apply([], document.getElementsByTagName("iframe")), document.getElementsByTagName("frame"));
16+
var frame, a, link, script, i, href, src;
17+
frame = [].concat.apply([].concat.apply([], document.getElementsByTagName('iframe')), document.getElementsByTagName('frame'));
3818
for(i = 0; i < frame.length; ++i) {
3919
if(frame[i].src) {
4020
src = frame[i].src; //Get absolute URL
@@ -55,6 +35,28 @@ var HTMLPreview = {
5535
}
5636
}
5737
}
38+
if(document.getElementsByTagName('frameset').length)
39+
return; //Don't replace CSS/JS if it's a frameset, because it will be erased by document.write()
40+
link = document.getElementsByTagName('link');
41+
for(i = 0; i < link.length; ++i) {
42+
if(link[i].rel
43+
&& link[i].rel.toLowerCase() == 'stylesheet'
44+
&& link[i].href) {
45+
href = link[i].href; //Get absolute URL
46+
if(href.indexOf('//raw.github.com') > 0 || href.indexOf('//bitbucket.org') > 0) { //Check if it's from raw.github.com or bitbucket.org
47+
HTMLPreview.send(href, 'loadCSS'); //Then load it using YQL
48+
}
49+
}
50+
}
51+
script = document.getElementsByTagName('script');
52+
for(i = 0; i < script.length; ++i) {
53+
if(script[i].src) {
54+
src = script[i].src; //Get absolute URL
55+
if(src.indexOf('//raw.github.com') > 0 || src.indexOf('//bitbucket.org') > 0) { //Check if it's from raw.github.com or bitbucket.org
56+
HTMLPreview.send(src, 'loadJS'); //Then load it using YQL
57+
}
58+
}
59+
}
5860
},
5961

6062
loadHTML: function(data) {

htmlpreview.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)