spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column73


Netscape 6, Part II: Animation

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Moving Objects Vertically

Let's focus now on the vertical location of an object, usually associated with the word top. Netscape Navigator uses the top property of an element. Internet Explorer uses the pixelTop property of the style object property. Netscape 6 uses the W3C Standard's top property of the style object property. Since Internet Explorer 5+ supports this property as well, we can use the following browser-independent code to move objects vertically:

<FORM>
<INPUT ID="counter1" STYLE="position:relative; top:0px" TYPE="button"
VALUE="Move Button"
  onclick="document.getElementById('counter1').style.top = '15px';">
</FORM>

That renders like this:

Click the button and see it moving down by 15 pixels. Notice that the measurement (15) is specified with its units of measure (pixels). If you try to drop the px, you will get the same behavior. Here is the HTML above without px:

<FORM>
<INPUT ID="counter2" STYLE="position:relative; top:0" TYPE="button"
VALUE="Move Button"
  onclick="document.getElementById('counter2').style.top = 15;">
</FORM>

And you can play with it as well:

Next: How to set, get, initialize, and manipulate coordinates

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: December 18, 2000
Revised: December 18, 2000

URL: http://www.webreference.com/js/column73/5.html