Jump to content

Javascript Image Object


Shonumi
 Share

Recommended Posts

Couldn't help but notice that W3Schools does not include a section about creating the Image Object in JavaScript. Arrays, Boolean, String, Math, and others are certainly there. But I don't notice that it has anything about the Image Object. While granted, it's not the most quintessential thing out there, it shouldn't wholly be missing. At the very least, it makes the site all that more comprehensive. Just thought it was strange, as the JS Section doesn't seem complete, as there are several functions associated with the Image Object too, so it's not really a minor detail.

Link to comment
Share on other sites

The image object is just a wrapper for the <img> tag. So the image object has all the same properties as the tag

var img = new Image();//same as using DOM//var img = document.createElement("img");img.src="yourimage.gif";img.border = "0";img.alt = "Alt text";//etc,etc

Using the DOM is the recmmended way although it really makes no difference.

Link to comment
Share on other sites

Okay, that's fine. I just didn't see the Image Object with the rest of them (silly me). But I didn't see the HTML DOM way on how to create elements. The method createElement() is only found in the XML DOM tutorial but not the HTML DOM, which was part of the problem in me not recognizing the JS image object page was there. Since the DOM way is recommended, there could at least be an example of createElement() used for HTML. Perhaps I'm just blind like before, but I can't find it anywhere but in the XML DOM tutorial.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...