gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
can you give me code in order to display a spinner into an existing iframe, when i clic…
- User
can you give me code in order to display a spinner into an existing iframe, when i clic on a link, before the real content ?
- Assistant
Sure, here's an example of how you can display a spinner in an existing iframe before loading the real content when you click on a link:
HTML:
html<a href="https://example.com" onclick="showSpinner()">Click me</a> <iframe id="myFrame" style="display:none;"></iframe> <div id="spinner" style="display:none;">Loading...</div>JavaScript:
javascriptfunction showSpinner() { document.getElementById('spinner').style.display = 'block'; document.getElementById('myFrame').style.display = 'block'; // Set the iframe source document.getElementById('myFrame').src = 'https://example.com'; // Wait for the iframe content to load document.getElementById('myFrame').onload = hideSpinner; } function hideSpinner() { document.getElementById('spinner').style.display = 'none'; }