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

295
Visualizações
How to get or call Javascript var in HTML object tag or HTML embed tag from parent html page?

I have embedded a codmirror html file by 3 different way such as iframe tag, embed tag and object tag inside another html file on the same server.

<!-- The Codemirror Modal window-->
<div id="codeMirrorModal" class="modal">
  <!-- Modal content -->
  <div class="modal-content">
    <span class="close">&times;</span>
    <iframe id="cmIframeId" class="iframeStyle" name="cmiframe" src="../html/codemirror.html" ></iframe>
    
    <embed id="cmEmbed" type="text/html" src="../html/codemirror.html" width="800" height="500">
    
    <object id="cmObject" data="../html/codemirror.html" width="800" height="800" type="text/html"> </object>
    
  </div>
</div>

I can initialize the content of codemirror by iframe but I don't know how to initialize it by embed and object tag.

function openAndInitializeCodeMirror() {
        var modal = document.getElementById("codeMirrorModal");
        modal.style.display = "block";
        
        var content = editor.getContent();

        // with success
        var iframe = document.getElementById("cmIframeId");         
        iframe.contentWindow.codeMirrorEditor.setValue(content);
        
        // no success           
        var embed = document.getElementById("cmEmbed");
        embed.contentDocument.codeMirrorEditor.setValue(content);

        // no success           
        var object = document.getElementById("cmObject");
        var myData = object.contentDocument.body.childNodes[0].innerHTML;

}
    

var codeMirrorEditor is an instance of codemirror on the embedded page.

How can I access or call the codeMirrorEditor instance on the embeded page from parent page to initialize it by my content?

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