Passing paramiter to new window & use of it

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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:
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.


Re: Passing paramiter to new window & use of it

P.L. Owens wrote:

Quoted text here. Click to load it

Did you post this question a couple hours ago in other newsgroups? Just

Re: Passing paramiter to new window & use of it

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.


Quoted text here. Click to load it
the? in
Quoted text here. Click to load it

Re: Passing paramiter to new window & use of it

P.L. Owens wrote:

Quoted text here. Click to load it

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 -

Re: Passing paramiter to new window & use of it


Quoted text here. Click to load it

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
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
<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 [i].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;

// -->    

</head><body  >

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


END - Client-side image - viewer code

Placing the code into the parent window can use either to open a window as we've already described, or it
might use 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 ="", "_imagegallery",
var docImageView =wndViewer .document;
docImageView.write("<title>" + title + "</title>")
docImageView.write("<img src='" + src + "' />");

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
 'Reconstructing an existing modern garage in a more sympathetic
timber framed vernacular, preserving the original roof cladding to
reduce costs.');"            
Quoted text here. Click to load it

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 .

Site Timeline