Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

127
Visualizações
I want to change the src value through a for statement

I want to get the iframe through the for statement. And I want to put different numbered html files in iframe. I've tried, but src doesn't work as a for statement. I've tried a lot, but it's too difficult for me. help me plz..

original code

        const elements = document.getElementsByClassName("book"), bubbles = false;

        const observer = new WebKitMutationObserver(function (mutations) {
            mutations.forEach(attrModified);
        });

        for (var i = 0; i < elements.length; i++) {
            observer.observe(elements[i], { attributes: true, subtree: bubbles });
        }

        function attrModified(mutation) {
            const contentStyle = mutation.target.getAttribute("style");
            const IsVisible = contentStyle.indexOf("block") != -1;
            if (!IsVisible) {
                const currentIframe = $(mutation.target).children("iframe");
                currentIframe.attr("src", "./iframe_model/model01.html");
            }
            else {
                const link = $(mutation.target).data("link");
                const currentIframe = $(mutation.target).children("iframe");
                currentIframe.attr("src", link);
            }
            
        }

code i want

        const iframe = document.querySelectorAll(".if");
        let currentPageNumber = 1;
        for(var i = 0; i < iframe.length; i++) {
            iframe[i].src="./iframe_model/model0" + currentPageNumber++ + ".html";
            currentPageNumber++;
        }

code i tried

        const elements = document.getElementsByClassName("book"), bubbles = false;
        const observer = new WebKitMutationObserver(function (mutations) {
            mutations.forEach(attrModified);
        });

        for (var i = 0; i < elements.length; i++) {
            observer.observe(elements[i], { attributes: true, subtree: bubbles });
        }

        function attrModified(mutation) {
            const contentStyle = mutation.target.getAttribute("style");
            const IsVisible = contentStyle.indexOf("block") != -1;
            if (!IsVisible) {
                let currentIframe = $(mutation.target).children("iframe");
                let currentPageNumber = 1;
                // currentIframe.attr("src", "./iframe_model/model01.html");
                for(var j = 0; j < currentIframe.length; j++) {
                    currentIframe[j].src="./iframe_model/model0" + currentPageNumber++ + ".html";
                    currentPageNumber++;
                }
            }

            else {
                code comments
            }
            
        }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda