Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Resize image down....only if larger than 400 pixels?

    Hello,

    I am looking for some assistance if anyone would be willing to offer some.

    I need to write a javascript to resize an image down to 400 pixels in width....but only if the image is greater than that value.

    If the image is smaller than 400 pixels, I don't want it to resize. I'm sure this is simple and I'm hoping someone may be able to point me in the right direction.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Do you mean something like this


    <HTML>
    <HEAD>
    <TITLE>Document Title</TITLE>

    <script>
    function test(){
    if(document.mypic.width>400){
    document.mypic.width=400
    }
    }
    </script>

    </HEAD>
    <BODY onload="test()">


    <img name="mypic" src="pic.jpg">
    </BODY>
    </HTML>

  • #3
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes.....that does exactly what I was hoping.

    Thank you very much


  •  

    Posting Permissions

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