Culture: Difference between revisions
From Anarchy In Action
D A Earwig (talk | contribs) m (Test 2 iframe imbedding back to github api) |
D A Earwig (talk | contribs) m (Test 3 iframe) |
||
Line 8: | Line 8: | ||
<iframe id="github-iframe" src=""></iframe> | <iframe id="github-iframe" src=""></iframe> | ||
<script> | <script> | ||
fetch('https:// | // Fetch the raw content of the file from GitHub | ||
fetch('https://raw.githubusercontent.com/AnarchyInAction/TheGoldenPath/main/Data/FoodAgricultureWater') | |||
.then(function(response) { | .then(function(response) { | ||
return response. | // Check if the response is successful | ||
if (response.ok) { | |||
// Return the response text | |||
return response.text(); | |||
} | |||
// Throw an error if the response is not successful | |||
throw new Error('Network response was not ok.'); | |||
}).then(function(data) { | }).then(function(data) { | ||
// Get the iframe element | |||
var iframe = document.getElementById('github-iframe'); | var iframe = document.getElementById('github-iframe'); | ||
iframe. | // Set the srcdoc attribute with the fetched content | ||
iframe.srcdoc = data; | |||
}).catch(function(error) { | |||
// Log any errors to the console | |||
console.error('There was a problem with the fetch operation:', error); | |||
}); | }); | ||
</script> | </script> |
Revision as of 14:38, 18 March 2024
<!DOCTYPE html> <html> <head> <title>TEST</title> </head> <body> <iframe id="github-iframe" src=""></iframe> <script> // Fetch the raw content of the file from GitHub fetch('https://raw.githubusercontent.com/AnarchyInAction/TheGoldenPath/main/Data/FoodAgricultureWater') .then(function(response) { // Check if the response is successful if (response.ok) { // Return the response text return response.text(); } // Throw an error if the response is not successful throw new Error('Network response was not ok.'); }).then(function(data) { // Get the iframe element var iframe = document.getElementById('github-iframe'); // Set the srcdoc attribute with the fetched content iframe.srcdoc = data; }).catch(function(error) { // Log any errors to the console console.error('There was a problem with the fetch operation:', error); }); </script> </body> </html>