Purchase Advertising On AWT
 Upload & Sell Your Software
 Upload & Sell Your eBook
 Enter The AWT Control Panel  Contact Applied Web Tools
 Sell Your eBook @ The PDF Store  Password Troubles? Click Here!
Knowledge Center
Want to write for Applied Web Tools? Send your Writer's Query to
Editor@AppliedWebTools.net for details.
HTML
Reference
&
Tutorial
CSS
Reference
&
Tutorial
DOM
Reference
&
Tutorial
JavaScript
Reference
&
Tutorial
50+ Programming Examples
Use HTML, CSS, DOM & JavaScript Together
Misc. Essays & Documents
You'll Find Just About Anything In Here
50+ Web Page Constructions
Learn the Art of Using HTML, CSS, DOM & JavaScript Together
 Changing Background Colors
 Event Triggering With onLoad
 Disabling The Right Click
 DOM Driven Color Changing
 Switching Images
 innerHTML Attribute Access
 Change With innerHTML
 Changing Positions
 Change Position With onMouseMove
 Change Text Position
 Interactivity Skills
 Type-writing A Message
 Auto-changing Text Size
 Making Text Scroll
 Blinking Text
 Simple Form Authentication
 Change Background Color Of An INPUT
 Change Text Color Of An INPUT
 Change Background Image Of An INPUT
 Select All Checkboxes
 Select Color Of The Submit Button
 Change Text Color Of A Submit Button
 Insert Background Image To A Button
 Change Color Of Drop Down List
 Change Text Color Of A Drop Down List
 Change Color Of A TEXTAREA
 Change The Text Color Of A TEXTAREA
 Insert An Image Into A TEXTAREA
 Change The Size Of An Image
 Change The Source Of An Image
 Change The Position Of An Image
 Change The Background Image
 Moving Images Around The Page
 Drag & Drop An Image
 A Simple Image Viewer
 A Shaking Image
 A Digital Clock
 Drop Down List Link
 Top Drop Down Menu
 Always On Top Menu
 Inset Border Buttons
 A Description Generating Menu
 An Image Generating Menu
 A Horizontal Sliding Menu
 A Click Horizontal Sliding Menu
 Returning Cursor Co-ordinates
 Making Text Follow The Cursor
 Attaching An Image To The Cursor
change the position of an image

Have you ever been to a page that has a flying banner? There are many uses for this catchy display option. Some take this to an extreme, but for now we’ll keep it simple. This is a great exercise to quickly understand dynamic positioning concepts.

We’ll use both absolute and relative positioning techniques. The first position is absolute and the second position is relative to the first absolute position. You can use an increment operator (++) to change the document co-ordinates by ones if you wish, or even jump in increments of ten (or any given number) with the addition operator (+). The style.left attribute is used to give the image position in pixels. You can state a static value here or you can use a variable or array item to arrive at the new co-ordinate through scripted action.

The image can be any dimension or format, as long as the format is supported by the browser. Changing the image dynamically is also a good effect.

We use the getElementById() method to access the display properties for that image. This includes its position on the page. The id attribute must be stated with the IMG tag to allow the browser to figure out what element is to be positioned.

<html>
<head>

<script type="text/javascript">
function moveleft() {
document.getElementById('image').style.position="absolute";
document.getElementById('image').style.left="0";
}

function moveback() {
document.getElementById('image').style.position="relative";
}
</script>

</head>

<body>

<img id="image" src="bulbon.gif" onmouseover="moveleft()" onmouseout="moveback()">

</body>
</html>


To change back to the original position, a relative positioning method is used. It calls the original location of the image on the page and acts accordingly. If you’re going to move an image within a table in the page, you must account for the area that the image will be moved within or the table will automatically alter to fit the new image position. For example, if you were to move a 100 pixel wide image 10 pixels in both directions you would have to have a space given in the TD element containing it to be 120 pixels wide – 10 pixels to the left, 10 pixels to the right and the original 100 pixel wide image.
I do not employ cookies or tracking devices of any kind