Open iframe when clicking and download to date

0

I'm trying to implement a portal with revenue, expenses, etc. I am using iframes to bring the information from the server. It works fine until I realize that loading all iframes all at once shuffles the functions of every iframe because when it loads a iframe , it loads all functions within the function. I then need a code that makes iframe open at the time of the click and download to close it.

    window.onload = function() {
    //Receitas
    document.getElementById("iframe1").src="LINK_IFRAME1";
    document.getElementById("iframe2").src="LINK_IFRAME2";
    //Despesas
    document.getElementById("iframe3").src="LINK_IFRAME3";
    document.getElementById("iframe4").src="LINK_IFRAME4";
    document.getElementById("iframe5").src="LINK_IFRAME5";
    document.getElementById("iframe6").src="LINK_IFRAME6";
}

In html I'm bringing them like this:

<div class="modal fade" id="ingresso-de-receitas">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" class="blank" title="Fechar" data-dismiss="modal" aria-label="Fechar"><span aria-hidden="true">&times;</span></button>
                    <h2 class="modal-title">Ingresso de receitas</h2>
                </div>
                <div class="modal-body text-center">
                    <iframe id="iframe1" width="100%" height="900px" frameborder="none"></iframe>
                </div>
            </div>
        </div>
    </div>

Does anyone have any idea how to solve it?

    
asked by anonymous 11.02.2016 / 12:20

1 answer

0

I was able to resolve it as follows:

1 ° I create the modal normal, now where will be the iframe that in the case was in modal-body I left thus:

HTML

<iframe width="100%" height="900px" frameborder="none"></iframe>

In JavaScript I used this way:

$('#MyModal').on('show.bs.modal', function () {
$('#MyModal iframe').attr('src','LINK EXTERNO OU INTERNO');
})
$('#MyModal').on('hide.bs.modal', function () {
$('#MyModal iframe').removeAttr('src');
})

In this way modal opens, loads link and closing modal downloads iframe .

It works very well for those who use video sites. And do not leave the website heavy when loading the page at the beginning, only loading modal at the moment it is open.

    
13.02.2016 / 23:53