SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Open new window with only a picture in it

    Hi,

    Can anyone tell me how to open a new window with only a picture inside? The width and height of the window should fir the picture.

    THanks in advance

    ->Daniel.

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm only guessing - and not really concentrating - so let me know if it doesn't really work and we'll look at it more.

    you proably want to do something like:

    Code:
    var newWin=window.open('url.html','Picture','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizeable=0');
    
    newWin.document.open();
    var nImg=new Image();
    nImg.src = 'img.gif';
    newWin.document.appendChild(nImg);
    newWin.document.close();
    newWin.resizeTo(nImg.clientWidth, nImg.clientHeight);
    I don't know that clientWidth and Height will recieve the sizes correctly - you may otherwise try offset Width.
    Failing that - maybe screenWidth (though i don't think that's applicable) and finally style.pixelWidth ( though i am nearly sure that has to have the css width set! )

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  3. #3
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Flawless is pretty much right on the mark, but I will say this: I've tried using the resizeTo() method for this exact same purpose, and the results are less than dependable. The root of the problem is in the delay between the image FULLY loading so that the correct height/width can be used. Here's a file with the source code I used (and gave up on) If you get it to work better (or more consistently) let me know!

    http://www.peterbailey.net/js/imagepopup.js

    Just call the popImg() function from any event (usu. onClick) The only parameter is a string containing the img src.
    Code:
    <a href="javascript:popImg('images/photo.jpg')">Photo</a>
    -OR-
    <span onClick="popImg('images/photo.jpg')">Photo</span>
    You can see this working(sort of) online in the Inventory section at www.autolinkdallas.com
    EDIT: I just visited the Autolink site again myself, and it seems they've really screwed up their inventory system. The picture for the M3 listing works, too bad it's really a pic of a Benz :p
    Last edited by beetle; Jul 25, 2002 at 06:39.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  4. #4
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where's your signature from - too?!?!?

    And yes - resizeTo can be unpredictable.

    But you'll notice i used a new Image object - which
    /should/ load it faster.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  5. #5
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's a trilogy of comedies (kind of like Horror-spoofs) starring one main character, Ash.

    Evil Dead
    Evil Dead 2
    Army of Darkness

    All REAL funny. 'This is my BOOMstick' comes from Army of Darkness, which is arguably the best (unusual for sequels, eh?) You don't really need to watch the Evil Dead's to appreciate AoD. Anyhoo, he(Ash) is transported to a more medieval time, but manages to take a shotgun along for the ride...

    http://www.geocities.com/CollegePark...3/boomstic.wav

    http://www.houseofhorrors.com/armyof.htm
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  6. #6
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Flawless, your code doesn't work. I tried it but nothing popped up and it says error on page?

    Thanks

  7. #7
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes - it probably would ... it's completely untested!

    What line was the error in?

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  8. #8
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In Opera 6 a new blank page popped up.

    In IE 6 nothing happens. In status bar it says there are errors in page.

    Thanks

  9. #9
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should install a script debugger to get more info.

    Microsoft's one's good ( i think it comes with one of their
    sdk's)

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •