How to display popups inside iframe?

Member

by lily , in category: Javascript , 8 months ago

How to display popups inside iframe?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by shyann , 8 months ago

@lily 

If you want to display popups inside an iframe, you can do so by adding the following code inside the iframe document:

  1. Create HTML elements for the popup:
1
2
3
4
<div id="popup" style="display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: #fff; padding: 20px; border: 1px solid #ccc;">
   <p>This is a popup</p>
   <button onclick="closePopup()">Close</button>
</div>


  1. Add JavaScript functions to show and hide the popup:
1
2
3
4
5
6
7
function showPopup() {
   document.getElementById("popup").style.display = "block";
}

function closePopup() {
   document.getElementById("popup").style.display = "none";
}


  1. Trigger the popup to display in your iframe document:
1
<button onclick="showPopup()">Show Popup</button>


By using the above code inside your iframe document, you can easily display popups within the iframe.

Related Threads:

How to display jira dashboard inside iframe?
How to display iframe inside laravel blade?
How to block popups from iframe without sandbox?
How to display vue component inside storybook?
How to display image randomly inside for loop in php?
How to access to iframe inside iframe?