WordPress.org

Ready to get started?Download WordPress

Forums

Easy Modal
Iframe in the Modal (3 posts)

  1. andrezasv
    Member
    Posted 9 months ago #

    Hi,

    I'm opening an iframe inside the window modal. I noted that when I open the modal by the second time, it shows the iframe imediatly and seconds after it loads the iframe again.

    OBS.: I open the modal in a click event.

    How to avoid the modal to show the last content before reload the iframe?

    https://wordpress.org/plugins/easy-modal/

  2. danieliser
    Member
    Plugin Author

    Posted 9 months ago #

    Post your code so i can see whats going on.

  3. andrezasv
    Member
    Posted 9 months ago #

    Here is the code. I have a tab plugin within the modal and each tab has an iframe. So, at first time when I open the modal it is ok, but if I close the modal and open again it shows the iframe for some miliseconds and after it loads the iframe.

    [modal id=Test height=500 width=1000]
    
    [tabs title="" disabled="false" collapsible="true" active="0" event="click"]
    [tab title="Title of Tab 01"]<iframe onload='changeCssIFrameTodasPaginas();' id='iFrameTodasPaginas' width='1000' height='500'></iframe>[/tab]
    [tab title="Title of Tab 02"]<iframe onload='changeCssIFrameAddPagina();' id='iFrameAddPagina' width='1000' height='500'></iframe>[/tab]
    [/tabs]
    
    [/modal]  
    
    <script> function urlChange() {
    	var iFrameTodasPaginas = document.getElementById('iFrameTodasPaginas');
    	var iFrameAddPagina = document.getElementById('iFrameAddPagina');
    	iFrameTodasPaginas.src = 'site1.html';
    	iFrameAddPagina.src = 'site2.html';
    }
    </script>
    
    <script>
    function changeCssIFrameTodasPaginas() {
    	var iframeElement = document.getElementById('iFrameTodasPaginas');
    	var cssLink = document.createElement("link");
    	cssLink.href = "iframe.css";
    	cssLink.rel = "stylesheet";
    	cssLink.type = "text/css"; 
    
    	var iframeContent = (iframeElement.contentWindow || iframeElement.contentDocument);
    	if (iframeContent.document)
    		iframeContent = iframeContent.document;
    	iframeContent.getElementsByTagName('head')[0].appendChild(cssLink);
    }
    
    function changeCssIFrameAddPagina() {
    	var iframeElement = document.getElementById('iFrameAddPagina');
    	var cssLink = document.createElement("link");
    	cssLink.href = "http://wordpress9.hospedagemdesites.ws/wp-content/iframe.css";
    	cssLink.rel = "stylesheet";
    	cssLink.type = "text/css"; 
    
    	var iframeContent = (iframeElement.contentWindow || iframeElement.contentDocument);
    	if (iframeContent.document)
    		iframeContent = iframeContent.document;
    	iframeContent.getElementsByTagName('head')[0].appendChild(cssLink);
    }
    </script>

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.