Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

298
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda