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 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jan 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question changing window size to fit image

    http://www.allforchrist.cjb.net

    I want to automatically change the size of a window to fit the size of the image that is loaded in it when a picture is clicked in another window

    I already tried this:

    OpenWin.outerHeight=this.document.getElementById("Picture").height

    OpenWin.outerWidth=this.document.getElementById("Picture").width

    note :: the window name is OpenWin


    Please help..what do I do?
    Last edited by junnytony; 01-14-2003 at 06:10 AM.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I posted this a while back, will that work for you?
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    New to the CF scene
    Join Date
    Jan 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, beetle for the great help. That was exactly what I was looking for.

    But I have two more questions...

    How can I make the popup window be the focus everytime it loads an image? I've tried putting win.focus() but its not working.

    Secondly,
    The Scenerio:: I have a div element that loads images as the user chooses(id="picdiv").

    <div class='bigpic' style="visibility:hidden" id='picdiv'>
    <image ='center' src="pictureURL" name='bigpic'>
    <div class='bigpic' style="background-color:#888; height:20px; width:20px; top:7px; left:146px; padding:2px" id="xl">
    <a href="#" onclick="popImg(); return false;">XL</a>
    </div></div>



    I have another div element that is positioned on the image (id="xl") with a link that says XL. The onlclick event calls the function popImg() from here

    when I click the link, the popup window opens and is resized to fit the image in it. Thats fine.
    note that function popup gets the src using document.getElementById("bigpic").src

    Now, I want to know if there is a way I can load a larger version of the image in the popup window when the link "XL" is clicked. The larger image is in a different folder. I'm have a weird feeling there's no way to do this but somehow I think if characters of the src string can be cut off or retained, using a function like Len() in VisualBasic, the path can be redefined and combined usind the + operator.

    Any Insight into how this can be done would be appreciated

    If you want to understand better what I'm talking about, visit this link http://all4c.topcities.com/asps/pics.asp and click on any of the pictures.

    Thanks in advance

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ya, let's say, for example, that your small pics are in the subfolder small and the big pics are in the subfolder big

    document.getElementById("bigpic").src.replace( /\/small\//, "/big/" );

    That should send the proper source string to the function
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #5
    New to the CF scene
    Join Date
    Jan 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks again beetle.

    I'm confused about the subfolder thing. I mean the format for the src.replace(). The src for the small images is "../images/pics/picturename.jpg" and that of the large images is "../images/largepics/picturename.jpg".

    note that this is how the src's are included in the img statement:
    < img src="../images/pics/picturename.jpg">

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, then the line should look like this

    document.getElementById("bigpic").src.replace( /\/pics\//, "/largepics/" )

    The replace method uses regular expressions, a very handy tool to learn. Here's a post with some links

    replace()
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #7
    New to the CF scene
    Join Date
    Jan 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    thanks a lot beetle! Everything worked wonderfully


  •  

    Posting Permissions

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