Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6785923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:11:06+00:00 2026-05-26T17:11:06+00:00

I was trying to do this in an alert box only to find out

  • 0

I was trying to do this in an alert box only to find out that I can’t now. I cannot manage to get this to display at all. Instead of the variable I get [object HTMLImageElement]. I am missing something but what is it?

function joePic(){
    var joe_fat = new Image;
    joe_fat.src = "pic1.jpg";
    document.getElementById('photo').innerHTML = joe_fat;
}
<input type="button" value="Click here it find out" name="joePhoto" onclick="joePic()" 
height="150" width="150" />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:11:06+00:00Added an answer on May 26, 2026 at 5:11 pm

    Well, you’re trying to assign an Image as HTML, but it’s not HTML. It’s an Image.

    You have two options:

    1. Append joe_fat into the #photo element using the proper DOM function (which is appendChild) instead of pretending it’s a string of HTML:

      function joePic() {
          var joe_fat = new Image;
          joe_fat.src = "pic1.jpg";
      
          var photoElm = document.getElementById('photo');
          photoElm.innerHTML = '';        // clear target first
          photoElm.appendChild(joe_fat);  // now add image
      }
      
    2. Get rid of the Image object and actually do present a string of HTML instead:

      function joePic() {
         document.getElementById('photo').innerHTML = '<img src="pic1.jpg" />";
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make an alert box that appears only when the app is
I'm trying to get the following code to display only on specific pages but
I can't find a solution that works for me. I'm trying to preselect multiple
I'm trying to create a pop up box (with jQuery) that can handle forms,
I'm trying at this: var cur_border = $('id_grid_pic_'+cur_id).attr('border'); alert(cur_border); But the alert sends back
I'm trying to use this line to detect browser type: IE or Firefox. alert(isBrowser(Microsoft));
I am trying to update a table according to this trigger: CREATE TRIGGER alert
I'm trying to load a .json file with this line: $.getJSON('engines.json',{},function(data){ alert(data); }); If
I'm trying to make a notification area that will show alerts. return this.each(function() {
Im trying this, but when i press it it dont changes, it only displays

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.