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

190
Vistas
How to load element into a certain tag

How do I append the pdfObject to the div inside my HTML? I want to use the document.querySelector to get the id of the div and then load my PDF into there

here is my javascript function:

    showPDF: function (button) {
        let url = document.getElementById("URLinput").value;
        button.style.display = "none";
        let pdfObject = document.createElement("OBJECT");
        pdfObject.setAttribute("data", url);
        pdfObject.setAttribute("id", "pdf");
        let a = document.querySelector(selector)!= null;
        document.a.appendChild(pdfObject);
    },

and here is my HTML:

<head>
  <link rel="stylesheet" href="../css/pdfviewer.css">
</head>

<body>
  <h1>PDF Viewer</h1>
  <input id="show" type="button" value="PDF anzeigen" onclick="HM.PDFViewer.showPDF(this)"/>

  <input id="URLinput" type="text" value="/pdf/Doku.pdf"/>

  <script type="text/javascript" src="/js/pdfviewer.js"></script>

  <div id="selector"></div>
  <p> test </p>
</body>
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

EMBED's functionality has been standardized in HTML5 and is used to provide containers for plugins. The main problem with EMBED is its dependency on plugins to be loaded, which has become less common nowadays. Instead, you could either use IFRAME (which can include HTML pages and possibly other media) or OBJECT.

Modified version of your code:

showPDF: function (button) {
    let url = document.getElementById("URLinput").value;
    button.style.display = "none";
    let pdfObject = document.createElement("OBJECT");
    pdfObject.setAttribute("data", url);
    pdfObject.setAttribute("id", "pdf");
    document.body.appendChild(pdfObject);
}

This removes the dependency of having to use browser plugins or external JS libraries while also being widely supported.

about 4 years ago · Juan Pablo Isaza Denunciar

0

The modern browser is a text processor (rather than word processor) which is not a What You Serve Is What You Get (WHSIWYG) editor since the configuration is set by the 7 billion potential users. so here by comparison are Edge on the left and Firefox on the right with my base settings (no extra blockers are used).

Where from < Embed> < iFrame > and < Object > at least < iFrame> (W3 Recommended) is most consistent giving a download in both Edge and in FireFox, just the same as a traditional A Href=download would do.

enter image description here

As said each browser can block different aspects so in this one all 3 are blocked evenly so I can download whichever one I wish

enter image description here

Just to confirm why you cannot enforce a users view of a PDF in their editor here is yet another pdf browser view:-

enter image description here

about 4 years ago · Juan Pablo Isaza Denunciar
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