You are here: Reference > JavaScript > client-side > HTML DOM > objects > nodes and tags > input:image

input:image object

Browser support:
Creates an image control.
Same as the img tag. The image control allows the insertion of .jpg, .png, .bmp and .gif image files into the HTML document. If you want to create one or more clickable regions within an image, use the map element.

Syntax:

Methods that return the object:
var inputObj = document.createElement ("input");   inputObj.type = "image"
The base interface, through which you can add new functionalities to the input:image object, is the HTMLInputElement interface.
If you want to see the HTML objects by categories, please visit this page.
HTML page for this element: input:image

Possible members:

Properties
Methods
Events
Style properties
accessKey
Sets or retrieves an access key to an element.
align
Sets or retrieves the object's position with respect to the surrounding text.
alt
Sets or retrieves an alternate text that is displayed when the file associated with the element cannot be displayed.
attributes
Represents a collection of attribute nodes that belong to an element.
baseURI
10
Returns the base URL for the object.
behaviorUrns
Represents a collection of the Uniform Resource Names for all behaviors attached to an element.
border
Sets or retrieves the thickness of the border.
canHaveChildren
Retrieves a Boolean value that indicates whether the element can contain child elements.
canHaveHTML
Retrieves a Boolean value that indicates whether the element can contain HTML formatted text.
className
Sets or retrieves the style class or classes that belong to the element.
clientHeight
Returns the height of the visible area for an object, in pixels. The value contains the height with the padding, but it does not include the scrollBar, border, and the margin.
clientLeft
Returns the width of the left border in pixels.
clientTop
Returns the height of the top border in pixels.
clientWidth
Returns the width of the visible area for an object, in pixels. The value contains the width with the padding, but does not include the scrollBar, border, and the margin.
complete
Returns a Boolean value that indicates whether the loading of an element is finished or not.
contentEditable
3
Sets or retrieves whether the contents of the object are editable.
currentStyle
Represents the computed style settings for an element.
dir
Sets or retrieves the text direction as related to the lang property.
disabled
Sets or retrieves the state of an object for user interaction.
dynsrc
Sets or retrieves the location of a movie file or VRML.
filters
Represents a collection of all filter objects applied to an element.
form
Returns a reference to the form element in which the object is placed.
forms
Represents a collection of all form elements in the current document.
galleryImg
7
Sets or retrieves whether the My Pictures toolbar in Internet Explorer is enabled for the current img.
height
Specifies or returns the height of an element.
hideFocus
Specifies or returns whether a dotted rectangle (focus rectangle) is drawn around an object while it has focus.
hspace
Specifies or returns the number of pixels to use as a margin at the left and right sides of the object.
id
Sets or retrieves a unique identifier for the object.
isContentEditable
Returns a Boolean value that indicates whether the contents of the object are editable by the user.
isDisabled
Returns a Boolean value that indicates whether the object is disabled.
isMultiLine
Returns a Boolean value that indicates whether the contents of an element can be multiline or not.
isTextEdit
Returns a Boolean value that indicates whether the createTextRange method can be used for the element.
lang
Specifies or returns the language of the element.
language
Sets or retrieves the scripting language for the current element. Use it only for the script element.
localName
9
Returns the local part of the qualified name of the current node.
loop
Specifies or returns the number of repeats for a sound or video clip.
lowsrc
Specifies or returns the location of a lower resolution image to display.
name
Sets or retrieves the name of an element.
namespaceURI
93.6
Sets or returns the namespace URI of the current node.
nextElementSibling
93.5
Returns a reference to the next child element of the current element's parent.
nextSibling
Returns a reference to the next child of the current element's parent.
nodeName
Returns the name of the current node.
nodeType
Returns an integer that indicates the type of the node.
nodeValue
Sets or returns the value of the current node.
offsetHeight
Returns the height of the visible area for an object, in pixels. The value contains the height with the padding, scrollBar, and the border, but does not include the margin.
offsetLeft
Returns the left position of an object relative to the left side of its offsetParent element, in pixels.
offsetParent
Returns a reference to the closest ancestor element in the DOM hierarchy from which the position of the current element is calculated.
offsetTop
Returns the top position of the object relative to the top side of its offsetParent element, in pixels.
offsetWidth
Returns the width of the visible area for an object, in pixels. The value contains the width with the padding, scrollBar, and the border, but does not include the margin.
outerHTML
Sets or retrieves the outer HTML content (the source code including the opening and closing tags) of an element.
outerText
Sets or returns the text content of an element including the text content of its descendants.
ownerDocument
Returns the document object that contains the current node.
parentElement
Returns the parent element of the object in the DOM hierarchy.
parentNode
Returns the parent element of the current node in the DOM hierarchy.
parentTextEdit
Returns the closest ancestor element of the current element in the DOM hierarchy that can be used to create a TextRange object.
previousElementSibling
93.5
Returns a reference to the previous child element of the current element's parent.
previousSibling
Returns a reference to the previous node of the current element's parent.
readyState
Returns a string value that represents the state of the object.
recordNumber
Returns an integer value that indicates the ordinal position of the item within the data set that generated the current object.
runtimeStyle
Represents the overridden style settings for an element.
scopeName
Retrieves the local name of the namespace declared for the current element.
size
Specifies or returns the width of a control, in characters.
sourceIndex
Returns the position of the current object in the all collection of the document.
src
Sets or retrieves the location of an associated file for an object.
start
Specifies or returns the starting time of a video clip.
style
Represents the inline style settings for an element or a CSS rule.
tabIndex
Specifies or returns the tabbing order for keyboard navigation using the TAB key.
tagName
Returns the tag name of the current element.
tagUrn
Sets or retrieves the Uniform Resource Name (URN) of the namespace declared for the current element.
title
Specifies or returns a tooltip for an element.
type
Sets or retrieves the type of the input element.
uniqueID
Returns the unique identifier generated by the browser for the object.
unselectable
Sets or retrieves whether the selection process can start in an element's content.
useMap
Sets or retrieves the URL to use as an image map.
vspace
Specifies or returns the number of pixels to use as a margin at the top and bottom sides of an object.
width
Specifies or returns the default width of the element.

Example HTML code 1:

This example illustrates the use of the image element:
<input type="image" src="picture.gif" alt="picture" />
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates a simple image rotator in JavaScript:
<head>
    <script type="text/javascript">
        var imageFiles = ["picture.gif", "area.gif", "rainbow.gif"];
        function NextImage (imgId) {
            var img = document.getElementById (imgId);
            if (img.imageIdx === undefined) {
                img.imageIdx = -1;
            }
            img.imageIdx = (img.imageIdx + 1) % imageFiles.length;

            img.src = imageFiles[img.imageIdx];
        }
    </script>
</head>
<body onload="NextImage ('myImg')">
    <button onclick="NextImage ('myImg')">Change the image</button>
    <br /><br />
    <input type="image" id="myImg" width="100px" height="100px" />
</body>
Did you find this example helpful? yes no

Example HTML code 3:

This example shows how to create a new image element dynamically:
<head>
    <script type="text/javascript">
        function CreateNewImage () {
            var img = document.createElement ("input");
            img.type = "image";
            img.src = "picture.gif";

            var container = document.getElementById ("container");
            container.appendChild (img);
        }
    </script>
</head>
<body>
    <button onclick="CreateNewImage ();">Create new image</button>
    <div id="container"></div>
</body>
Did you find this example helpful? yes no

Related pages:

External links:

User Contributed Comments

Post Content

Post Content