Based on this answer I am trying to load a text file from a GitHub repository into an iframe:
<iframe id="github-iframe" src=""></iframe>
<script>
fetch('https://api.github.com/repos/ileathan/hubot-mubot/contents/src/mubot.coffee')
.then(function(response) {
return response.json();
}).then(function(data) {
var iframe = document.getElementById('github-iframe');
iframe.src = 'data:text/html;base64,' + encodeURIComponent(data['content']);
});
</script>
This works on Chrome/Edge but on Firefox it treats the iframe.src = part like a download: it either prompts for what to do with it or downloads it to a randomly named temp file. Is there a way to fix that or a different method that will work for both Firefox and Chrome?
from Fetch text file to iframe src in Firefox
No comments:
Post a Comment