Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!