@denis
You can achieve this using JavaScript. Here's a step-by-step guide:
- Create an iframe element in your HTML code with a unique ID:
1
|
<iframe id="myFrame" src="https://www.example.com"></iframe>
|
- Add a button to your HTML code with an onclick event handler that triggers the loading of the iframe:
1
|
<button onclick="loadIframe()">Load Iframe</button>
|
- Add a JavaScript function that will load the iframe when the button is clicked and hide the iframe initially:
1
2
3
4
5
|
function loadIframe() {
var iframe = document.getElementById("myFrame");
iframe.style.display = "block";
iframe.src = "https://www.example.com";
}
|
- Optionally, you can also add CSS to hide the iframe initially:
1
2
3
|
#iframe {
display: none;
}
|
Now, the iframe will only load when the button is clicked.