Skip to content

Commit 0d6cd42

Browse files
committed
More attempts to communicate between cdn hosted documentation embedded on openshot.org iframe
1 parent cf11f95 commit 0d6cd42

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

doc/_templates/layout.html

+21
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,26 @@
77
<!-- Adds target=_blank to external links -->
88
$('a[href^="http://"], a[href^="https://"]').not('a[class*=internal]').attr('target', '_blank');
99
});
10+
11+
// *** iFrame resize & scrolling support ***
12+
// Send the current page href to the parent site (if found)
13+
// Give up after 5 tries (for example, if viewing these pages
14+
// by themselves, with no parent openshot.org iFrame
15+
let messageAttempts = 0;
16+
function trySendMessage(){
17+
messageAttempts++;
18+
if ('parentIFrame' in window) {
19+
const href = frameElement.contentWindow.location.href;
20+
const type = "document-loaded";
21+
window.parentIFrame.sendMessage({href, type});
22+
} else {
23+
// If not, try again in one second
24+
if (messageAttempts < 5) {
25+
setTimeout(trySendMessage, 250);
26+
}
27+
}
28+
}
29+
trySendMessage();
30+
1031
</script>
1132
{% endblock %}

0 commit comments

Comments
 (0)