SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2003
    Location
    Texas
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Image in new window

    First, I wanted to let you know that I did search several times, and did a lot of reading, before posting this question.

    I've become somewhat frustrated with what I feel is a rather simple task. The goal is just to have a JavaScript function, or whatever works, to open up images in a new window.

    Such as:

    HTML
    Code:
    <a href="this is the big picture" target="functionnamehere?()"><img src="thumbnail"></a>
    JS
    Code:
    function thumbnail()
    {
    window.open("the URL would be here, but it's gonna be different for reach picture","bigpicture","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=480" )
    }
    I know that it's not right, and I thought that maybe I would need to do some sorta onClick thing, but I'm just rather confused right now. I guess I could've been wrong in assuming that this is an easy task, but I see sights all over the place that do something like this, or similiar to it, and I was looking to do the same.

  2. #2
    Pointiest Petitions carrotflowers's Avatar
    Join Date
    Jul 2003
    Location
    Suburbs of DC (MD)
    Posts
    595
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you need to write it in a function?

    If not, here is my code to have a link to new window for larger image, from one of my sites:
    <a href="#" onClick="window.open('larger_views/house_abington.html','','height=400,width=500');">
    <img src="images/houses/abington.jpg" alt="Abington, a Devco Home" height="100" border="0"></a>

    If there is a reason you want it in a function, I am pretty certain you can't place the call to the function in the target=""

    Instead you will need <a href="#" onclick="your function(imagename)"> and your function would need to take the image name as a parameter.Make sense?

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2003
    Location
    Texas
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried the method of passing the imagename as a variable of the function, but the name I specify in the function such as

    onclick="function(nameofpicture.jpg)"

    It says that "nameofpicture" is undeclared.

    If you want to get an idea of exactly what I'm doing, it's here:
    http://www.trepid.net/maps/images/bahsnah/

    This is just one gallery of images, and I'm looking to use the same function to call up these new windows for all pictures by specifying the function. See what I'm sayin?

    Ignore the current image sizes and all that for now, I'm trying to get this to work correctly first.

    Added: Ahh, ok, I fixed one problem. There needed to be single quotes around the variable name, but now to make the picture actually show up.

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2003
    Location
    Texas
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I can't seem to be able to for the actual image to appear.

    It just continues to try and open whatever I have for the "URL," which I have set as the variable name

    image

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2003
    Location
    Texas
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any ideas?

  6. #6
    Pointiest Petitions carrotflowers's Avatar
    Join Date
    Jul 2003
    Location
    Suburbs of DC (MD)
    Posts
    595
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks like you made some progress. I went to the page, and after it loads I can click once on any pic and get the larger image in new window. But then it doesn't work again, for that one or any of the others. Not sure what this line is your js is for:
    if( typeof(w) == "object" ) w.close();
    but I think that's why it only works one on page load.

    OK, I just removed that line and applied the js to a gallery page I have and it works fine. This was on Mac IE and Safari. On Mac NS 7 it worked even with that line. But I think ix nay on that ine lay.



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
  •