SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey folks..

    I am looking for a javascript that will give me complete freedom over a new window script. Basically, I want to be able to specify evrything in the A tag so that I can use this script across multiple windo sizes, types of files...etc...

    This is the one I have right now. It only lets me specify the file to be loaded (in the window) and the name of the window.

    function popUpImage(page,name) {
    props=window.open(page,name, 'toolbar=no,scrollbars=0,location=no,status=no,menubar=no,resizable=no,width=148,height=220');
    }

    and then I call it like so:
    <a href="javascriptopUpImage('gabe1.html','gabe1')">

    I want to be able to specify width and height of the window too. Can someone help me?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  2. #2
    SitePoint Zealot
    Join Date
    Nov 2000
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not sure if this answers your question,

    ------------------------------------

    <html>
    <head>
    <title>Untitled</title>
    </head>
    <script language="JavaScript1.2">

    function popUpImage(page,name,wd,ht) {
    var subWindow;
    subWindow = window.open(page,name, "toolbar=no,scrollbars=0,location=no,status=no,menubar=no,resizable=no");
    subWindow.resizeTo(wd,ht);
    }
    </script>
    <body bgcolor="#ffffff" text="#000000" id=all>
    <a href="javascript:popUpImage('blank.html','gabe1',25,25)">new window</a>

    </body>
    </html>

    -----------------------------------------

    This code works for Nav4 and IE5. (Maybe other version, I haven't tested it any further.)

    Hope this helps.

  3. #3
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Or in a form similar to your original code:

    Code:
    function popUpImage(page,name,width,height) { 
    props=window.open(page,name, 'toolbar=no,scrollbars=0,location=no,status=no,menubar=no,resizable=no,width="+width+",height="+height); 
    }
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  4. #4
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys, those both look good. Kevin...the weird thing is, through messing around with the code, I came up with almost the EXACT same code. I think the only difference was that I had single quotes where you have double quotes.

    i'll them both a try.

    thanks again that's a BIG help.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  5. #5
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Er, yes. You can use either quoting style -- but they must match (unlike my code above, which won't work). Doh.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  6. #6
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it won't work? What should I change in it to get it to work? Also, how should I call it? I am doing it this way for right now because I want to change as little code as possible.

    <a href="javascript:void();" onMouseOver="displayStatusMsg('Plus One Pictures');return document.returnValue" onClick="popUpImage('../images/tour_image_13.jpg','popWin13','480','360')">
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  7. #7
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually...I have an additional question. How would I use this script (or another if necessary) in conjunction with a database.

    Say for example, I want to use a "template" page for every popup picture on my site. Would there be a way to call that same page every time and pass it the name of the actual image I want using Javascript or PHP?

    the "template" page would look something like this:

    <html>
    <body>
    <img src="$image_name" width="$width" height="$height" border="0"><br>
    <a href="javascript:window.close">
    </body>
    </html>

    The reason I have for doing it this way is if you call the image by itself in a blank window, there is unsightly white space resulting from the margins of the browser. If I call a "page" then I can set margins.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  8. #8
    SitePoint Zealot
    Join Date
    Nov 2000
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am just working out of the blue here, but this may work.

    ------------ image.php -------------
    <html>
    <body bgcolor="#ffffff" text="#000000" id=all>

    <?php

    echo("<img src=" . $image_name ." width=" . $width . " height=" . $height . " border=0><br>")

    ?>

    </body>
    </html>

    ------------------------------------
    ------------- file.html ------------
    <html>
    <body bgcolor="#ffffff" text="#000000" id=all>
    <a href="image.php?image_name=car.gif&width=233&height=244">show image</a>
    </body>
    </html>
    -------------------------------------

    Again it works, but you have to change a few things, the images and change it so it opens in a new window with javascript.



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
  •