Använder nu postMessage för att få över variabler till iframe
This commit is contained in:
@@ -15,15 +15,27 @@
|
|||||||
srcdoc="{{ client_content }}">
|
srcdoc="{{ client_content }}">
|
||||||
</iframe>
|
</iframe>
|
||||||
|
|
||||||
<script>
|
<!-- <script>
|
||||||
// Extract apiEndpoint for use in your frontend code...
|
// Extract apiEndpoint for use in your frontend code...
|
||||||
const apiEndpoint = '{{ api_endpoint }}'; // Templating syntax (Jinja2)
|
const apiEndpoint = '{{ api_endpoint }}'; // Templating syntax (Jinja2)
|
||||||
const useModel = '{{ use_model }}'; // Templating syntax (Jinja2)
|
const useModel = '{{ use_model }}'; // Templating syntax (Jinja2)
|
||||||
// Tell the iframe about the apiEndpoing
|
// Tell the iframe about the apiEndpoint
|
||||||
document.getElementById('client-frame').contentWindow.apiEndpoint = apiEndpoint;
|
document.getElementById('client-frame').contentWindow.apiEndpoint = apiEndpoint;
|
||||||
document.getElementById('client-frame').contentWindow.useModel = useModel;
|
document.getElementById('client-frame').contentWindow.useModel = useModel;
|
||||||
console.log("index.html - API Endpoint: ", apiEndpoint);
|
console.log("index.html - API Endpoint: ", apiEndpoint);
|
||||||
console.log("index.html - use model: ", useModel);
|
console.log("index.html - use model: ", useModel);
|
||||||
|
</script> -->
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Extract apiEndpoint for use in frontend.js
|
||||||
|
const apiEndpoint = '{{ api_endpoint }}'; // Templating syntax (Jinja2)
|
||||||
|
const useModel = '{{ use_model }}'; // Templating syntax (Jinja2)
|
||||||
|
window.addEventListener('load', function() {
|
||||||
|
const clientFrame = document.getElementById('client-frame').contentWindow;
|
||||||
|
clientFrame.postMessage({ apiEndpoint, useModel }, '*'); // Send the data to the iframe
|
||||||
|
});
|
||||||
|
console.log("index.html - API Endpoint: ", apiEndpoint);
|
||||||
|
console.log("index.html - use model: ", useModel);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Responsive scaling and some padding -->
|
<!-- Responsive scaling and some padding -->
|
||||||
|
|||||||
Reference in New Issue
Block a user