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

150
Views
How to modify <object> data attribute for Google Chrome?

I am trying to change the data attribute of an element with id 'previewImage'. I modify the attribute by doing an Ajax call to another file, and get back the data. All browsers shows the data received from the AJAX-call (image or PDF) (encoded base64), except Google Chrome. Is there an solution for this?

I saw this answer earlier, but I think it is deprecated (it did not work for me): <object> works in every browser except Google Chrome

Ajax Call:

function getFile(id, r = false)
{
    timer = setTimeout(function(){
        $.ajax({
            url: "/project/getFile",
            method: "POST",
            data: {id: id}
        })
            .done(function(data)
            {
                $('#previewImage').prop('data', data);
            })
    }, 100)
}

object:

<object id="previewImage" class="w-100" style="min-height: 500px">
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Thanks for the help everyone! I changed the object tag to an Iframe, witch made the following:

<iframe id="previewImage" class="w-100" height="500px"></iframe>

The AJAX-call stayed almost the same:

function getFile(id, r = false)
    {
        timer = setTimeout(function(){
            $.ajax({
                url: "/project/getFile",
                method: "POST",
                data: {id: id}
            })
                .done(function(data)
                {
                    $('#previewImage').prop('src', data);
                    $('#previewImage image').css("width: 100%")
                })
        }, 100)
    }

This worked for me!

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!