Results 1 to 7 of 7

Thread: positioning images with javascript.

  1. #1
    Join Date
    Jan 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default positioning images with javascript.

    Hi All,
    I have no specific reference to give you. Rather new to javascript, fully conversant on CSS HTML etc If i borrow a javascript from someone else and wish to change the position of images how can i do it. What commands are available except for the <center> and using <br /> all the time. I have searched the entire internet and havent found a decent answer. Appreciate any ideas?

    Käse

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You can set document.images['imageNameOrID'].style.offsetLeft and .offsetTop as you like.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thanks

    Thanks, But where exactly to insert this text. In the script, body or style? Does anyone know of anymore image commands for position = absolute etc for Javascript. Or using CSS commands on a pre-written javascript. Any input would be much appreciated.

    Käse

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    But where exactly to insert this text. In the script, body or style?
    A script, of course. The image must be absolutely positioned. Don't use my code directly; it's only informational. CSS attributes can be set in Javascript with element.style.attributeName, where element is an element object. The only thing you need to watch out for is that hyphens are replaced by camel notation; for example, background-color becomes backgroundColor.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jan 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thanks again.

    Could you point me in the direction of some examples to follow? Thanks in advance

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Move image with name/id of "irge" to 60x20 from the top of the page:
    Code:
    <script type="text/javascript">
    var e = document.images['irge'].style;
    e.position = "absolute";
    e.offsetLeft = "60px";
    e.offsetTop = "20px";
    </script>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Jan 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thanks

    Thanks so much!!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •