Passing paramiter to new window & use of it

Discussion in 'HTML' started by P.L. Owens, Feb 8, 2004.

  1. P.L. Owens

    P.L. Owens Guest

    I am trying to open a pop-up window with its own htm code, in order to show
    an enlargement of a thumbnail. But I am passing a query string after the? in
    the url of the new window. for example:
    www.helpme.com?newpic.jpg
    I am then trying to put the query string in
    <IMG SRC="querystring" WIDTH=400 BORDER=0>.
    I don't know how to get the query string to echo "newpic.jpg" in the htm
    command in the pop up window.

    Thank You.

    Paul
     
    P.L. Owens, Feb 8, 2004
    #1
    1. Advertising

  2. P.L. Owens

    DU Guest

    P.L. Owens wrote:

    > I am trying to open a pop-up window with its own htm code, in order to show
    > an enlargement of a thumbnail. But I am passing a query string after the? in
    > the url of the new window. for example:
    > www.helpme.com?newpic.jpg
    > I am then trying to put the query string in
    > <IMG SRC="querystring" WIDTH=400 BORDER=0>.
    > I don't know how to get the query string to echo "newpic.jpg" in the htm
    > command in the pop up window.
    >
    > Thank You.
    >
    > Paul
    >
    >


    Did you post this question a couple hours ago in other newsgroups? Just
    asking...
     
    DU, Feb 8, 2004
    #2
    1. Advertising

  3. P.L. Owens

    P.L. Owens Guest

    Yes, on comp.lang.javascript but the answer did not quite work. Appreciated
    it, but still trying to get some type of solution to the problem.

    Paul

    "DU" <> wrote in message
    news:c044ri$dsg$...
    > P.L. Owens wrote:
    >
    > > I am trying to open a pop-up window with its own htm code, in order to

    show
    > > an enlargement of a thumbnail. But I am passing a query string after

    the? in
    > > the url of the new window. for example:
    > > www.helpme.com?newpic.jpg
    > > I am then trying to put the query string in
    > > <IMG SRC="querystring" WIDTH=400 BORDER=0>.
    > > I don't know how to get the query string to echo "newpic.jpg" in the htm
    > > command in the pop up window.
    > >
    > > Thank You.
    > >
    > > Paul
    > >
    > >

    >
    > Did you post this question a couple hours ago in other newsgroups? Just
    > asking...
     
    P.L. Owens, Feb 8, 2004
    #3
  4. P.L. Owens wrote:

    > I am then trying to put the query string in
    > <IMG SRC="querystring" WIDTH=400 BORDER=0>.


    If your server supports PHP, you could use something like:

    <IMG SRC="<?= getenv('QUERY_STRING') ?>" WIDTH=400 BORDER=0>

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?page=132
     
    Toby A Inkster, Feb 8, 2004
    #4
  5. P.L. Owens

    Andy Dingley Guest

    On Sat, 7 Feb 2004 17:33:03 -0800, "P.L. Owens" <>
    wrote:

    >I am trying to open a pop-up window with its own htm code, in order to show
    >an enlargement of a thumbnail. But I am passing a query string after the? in
    >the url of the new window.


    HTML isn't executable code, so you can't do this in pure HTML alone.
    You need some scripting somewhere, either on the server (probably
    easiest), in the new window (JavaScript) or in the parent window with
    the thumbnails (more JavaScript) .

    Server-side code is easiest. Make a link URL like
    www.helpme.com/image.php?image=newpic.jpg
    image.php is a new script you write to load up the image you want.
    Quite how you do this depends on what your server supports - it could
    be PHP, but equally well Perl, ASP etc.


    If you put the code client-side into the image viewing window, then
    you need to extract the parameter from the URL, slice it up to an
    image identifer, turn it into a relative URL, then write it into the
    ..src property of the <img> element.

    BEGIN - Client-side image - viewer code
    -------------------------------------------------------
    <html><head>
    <title>Image viewer</title>

    <script language="JavaScript" type="text/javascript" >
    <!-- //

    window.onload = function () {

    // Deal with the parameters
    var strURL = document.URL;
    var strQueryString = strURL.match (/\?(.+)$/);
    if (strQueryString != null) {
    var aryQueryStrings = strQueryString [1].split (/\&/);
    var aryQueryParams = new Array();
    for (var i=0; i < aryQueryStrings.length; i++) {
    var strQueryParams = aryQueryStrings .split
    (/=/);
    if (strQueryParams) {
    aryQueryParams [strQueryParams [0]] =
    strQueryParams [1];
    }
    }
    }

    // Find the properties
    var strImageID = aryQueryParams ['image'];
    // Force a file extension
    if (!strImageID.match (/\.jpg$/i)) { strImageID += '.jpg'; }
    var strBaseURL = "\/ebay\/201203\/"; // Could load this
    from params too

    // Might test here and exit if there's no image to load


    var strSrcURL = strBaseURL + strImageID;
    // Could read these from the image, take it from a parameter
    or anything
    var strTitle = "Image " + strImageID;
    var strLongDesc = "URL " + strURL + "\nImage " + strImageID;

    // Find the targets and display the properties
    document.title = strTitle;
    var elmImg = document.all.imgZoom;
    if (elmImg) {
    elmImg.src = strSrcURL;
    elmImg.alt = strTitle;
    elmImg.longdesc = strLongDesc;
    }
    var divCaption = document.all.divCaption;
    if (divCaption) {
    divCaption.innerText = strLongDesc;
    }
    }

    // -->
    </script>


    </head><body >

    <img id="imgZoom" src="" alt="" />
    <p id="divCaption" class="caption" ></p>

    </body></html>

    -----------------------------------------------------
    END - Client-side image - viewer code




    Placing the code into the parent window can use either
    window.open(URL) to open a window as we've already described, or it
    might use window.open() and then use document.write() to generate the
    HTML within it. I like this method myself, as it avoids another round
    trip to the server.

    var wndViewer = window.open("", "_imagegallery",
    "height=500,width=500,menubar=no,resizable=yes")

    var docImageView =wndViewer .document;
    docImageView.write("<html><head>")
    docImageView.write("<title>" + title + "</title>")
    docImageView.write("</head><body>")
    docImageView.write("<img src='" + src + "' />");
    docImageView.write("</body></html>")

    wndViewer.focus();
    return true; // Success




    When you call the "view large image" code from the thumbnail gallery,
    I suggest using code like this:

    <a href="photos/im000501.jpg" target="_imageview"
    onclick="return gallery_onclick('photos/im000501.jpg', 'Ashwell
    Barn',
    'Reconstructing an existing modern garage in a more sympathetic
    timber framed vernacular, preserving the original roof cladding to
    reduce costs.');"
    ><img src="photos/im000501_thumbnail.jpg" alt="Ashwell Barn" /></a>


    gallery_onclick() returns true if successful, which terminates
    navigation at that point. However if JavaScript isn't available to
    that client, then the normal <a href="" > navigation takes its place
    and you get a non-JavaScript window opened .
     
    Andy Dingley, Feb 8, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Tm92aWNl?=
    Replies:
    2
    Views:
    6,666
    Alan Ferrandiz Langley
    Jun 9, 2004
  2. Matt
    Replies:
    2
    Views:
    13,989
    bruce barker
    Aug 23, 2004
  3. Matt
    Replies:
    1
    Views:
    439
    Andrew Thompson
    Aug 22, 2004
  4. Matt
    Replies:
    5
    Views:
    3,044
    Michael Winter
    Aug 25, 2004
  5. Gordon
    Replies:
    3
    Views:
    310
    Steven Burn
    Apr 16, 2004
Loading...

Share This Page