Popup Window Resizes To Fit Image

My page has a bunch of thumbnails. When the user clicks a thumbnail, I use the following function to open a popup window which resizes the window to fit the image:

THUMBS.HTM
----------------
<script language='javascript'>
function PopupPic(sPicURL) {
  window.open( "popup.asp?"+sPicURL, "", "resizable=1,HEIGHT=200,WIDTH=200")
 
}
</script>

<a href="javascript:PopupPic('images/options/topdeckanchorlock.jpg')">

POPUP.ASP
-------------
 <script language='javascript'>
   var arrTemp=self.location.href.split("?");
   var picUrl = (arrTemp.length>0)?arrTemp[1]:"";
   var NS = (navigator.appName=="Netscape")?true:false;

     function FitPic() {
       iWidth = (NS)?window.innerWidth:document.body.clientWidth;
       iHeight = (NS)?window.innerHeight:document.body.clientHeight;
       iWidth = document.images[0].width - iWidth;
       iHeight = document.images[0].height - iHeight;
       window.resizeBy(iWidth, iHeight);
       self.focus();
     };
 </script>

<body onload='FitPic();' topmargin="0" marginheight="0" leftmargin="0" marginwidth="0">

<script language='javascript'>
 document.write( "<img src='" + picUrl + "' border=0>" );
</script>

Question: how can I add and pass along a description in THUMBS.HTM and then write it out on POPUP.ASP?


Thanks!
LVL 3
yourbudweiserAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VirusMinusCommented:
try this ->

THUMBS.HTM
----------------
<script language='javascript'>
function PopupPic(sPicURL, sPicDesc) {
  window.open( "popup.asp?"+sPicURL+"&"+sPicDesc, "", "resizable=1,HEIGHT=200,WIDTH=200")
 
}
</script>

<a href="javascript:PopupPic('images/options/topdeckanchorlock.jpg','picture description')">

POPUP.ASP
-------------
 <script language='javascript'>
   var arrTemp=self.location.href.split("?");
   var picUrl = (arrTemp.length>0)?arrTemp[1]:"";
   var arrTemp=self.location.href.split("&");
   var picDesc = (arrTemp.length>0)?arrTemp[1]:"";
   var NS = (navigator.appName=="Netscape")?true:false;

     function FitPic() {
       iWidth = (NS)?window.innerWidth:document.body.clientWidth;
       iHeight = (NS)?window.innerHeight:document.body.clientHeight;
       iWidth = document.images[0].width - iWidth;
       iHeight = document.images[0].height - iHeight;
       window.resizeBy(iWidth, iHeight);
       self.focus();
     };
 </script>

<body onload='FitPic();' topmargin="0" marginheight="0" leftmargin="0" marginwidth="0">

<script language='javascript'>
 document.write( "<img src='" + picUrl + "' border=0><br>" + picDesc  );
</script>
0
VirusMinusCommented:
alternately because you are using ASP you could also do this ->

THUMBS.HTM
----------------
<script language='javascript'>
function PopupPic(sPicURL, sPicDesc) {
  window.open( "popup.asp?picURL="+sPicURL+"&picDesc="+sPicDesc, "", "resizable=1,HEIGHT=200,WIDTH=200")
 
}
</script>

<a href="javascript:PopupPic('images/options/topdeckanchorlock.jpg','picture description')">

POPUP.ASP
-------------
<%
Dim picURL, picDesc
picURL = Request.QueryString("picURL")
picDesc = Request.QueryString("picDesc")
%>

 <script language='javascript'>
//   commented out beacause it is being done in ASP
//   var arrTemp=self.location.href.split("?");
//   var picUrl = (arrTemp.length>0)?arrTemp[1]:"";
//   var arrTemp=self.location.href.split("&");
//   var picDesc = (arrTemp.length>0)?arrTemp[1]:"";

   var NS = (navigator.appName=="Netscape")?true:false;

     function FitPic() {
       iWidth = (NS)?window.innerWidth:document.body.clientWidth;
       iHeight = (NS)?window.innerHeight:document.body.clientHeight;
       iWidth = document.images[0].width - iWidth;
       iHeight = document.images[0].height - iHeight;
       window.resizeBy(iWidth, iHeight);
       self.focus();
     };
 </script>

<body onload='FitPic();' topmargin="0" marginheight="0" leftmargin="0" marginwidth="0">

<script language='javascript'>
 document.write( "<img src='" + <%= picURL %> + "' border=0><br>" + <%= picDesc %>  );
</script>
0
yourbudweiserAuthor Commented:
VirusMinus, thanks alot for responding. Unfortunately, neither of your responses worked. The window pops open but no image appears in it. Any ideas?

Thanks.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

VirusMinusCommented:
what comes up? can u view the source of the popup and paste it? If a red 'X' comes up we can see where the path of the image is pointing to.
0
VirusMinusCommented:
i just noticed.. both solutions are missing </body> </html> at the end
0
VirusMinusCommented:
ok i've tested these..

Here's thumbs.htm
-=-=-=-=-=-=-=-=-=-=-=-=-

<html>
<head>
<script language='javascript'>
function PopupPic(sPicURL, sPicDesc) {
  window.open( "popup.htm?picURL="+sPicURL+"&picDesc="+sPicDesc, "", "resizable=1,HEIGHT=200,WIDTH=200")
 }
</script>
</head>
<body>
  <center>
  <div style="margin-left:auto;margin-right:auto;width:500px;">
  <table border=1 width=100% bgcolor=#FFFFCC height=500>
       <tr><td><div id=blah style="position:relative; left:100; top:200;">


<a href="javascript:PopupPic('images/home.jpg','picture description')">here</a>

         </div></td></tr>
  </table>
  </div>
</body>
</html>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
also note I'm passing the querystrings the way they're supposed to be passed, i.e.
popup.htm?picURL=images/sadasd.jpg&picDesc=picture description
and here's popup.asp or popup.htm, you can call it whatever... there's no ASP.
I'm calling it popup.htm
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

<html>
<head>
 <script language='javascript'>
      function myunescape(s){
       for(var i=0;i<s.length;i++){
         if(s.charAt(i)=='+'){
           s=s.substring(0,i)+" "+s.substring(i+1);
         }
       }
       return unescape(s)
      }
            
      function querystring(name)
      {tmp = location.search;
       while(tmp.length>1){
         tmp=tmp.substring(1); // chop first ? or &
         inx=tmp.indexOf("&");
         if(inx<0) inx=tmp.length;
         t=tmp.substring(0,inx);
      
         tmp=tmp.substring(inx);
         inx=t.indexOf("=");
         n=myunescape(t.substring(0,inx));
         v=myunescape(t.substring(inx+1));
         if(n==name){
           return v;
        }
       }
       return null
      }
      
      var picURL = querystring('picURL');
      var picDesc = querystring('picDesc');
    var NS = (navigator.appName=="Netscape")?true:false;

     function FitPic() {
       iWidth = (NS)?window.innerWidth-2:document.body.clientWidth-2;
       iHeight = (NS)?window.innerHeight-25:document.body.clientHeight-25;
       iWidth = document.images[0].width - iWidth;
       iHeight = document.images[0].height - iHeight;
       window.resizeBy(iWidth, iHeight);
         centerWindow();
       self.focus();
     }
 </script>
</head>
<body onload='FitPic();' topmargin="0" marginheight="0" leftmargin="0" marginwidth="0">
<script language='javascript'>
 document.write( "<center><img src='" + picURL + "' border=0><br>" + picDesc + "</center>");
</script>
</body>
</html>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yourbudweiserAuthor Commented:
Actually figured this one out based on your previous answer so thanks! Here's the solution I am using:

THUMBS.HTM
----------------
<script language="Javascript">
    function PopupPic(sPicURL) {
      newWin=window.open( sPicURL, 'newWin','resizable=1,HEIGHT=200,WIDTH=200');
      newWin.focus();
    }
</script>

<a href="popup.asp?image=images/options/keywestttop.jpg&desc=Key West T-Top" onclick="PopupPic(this.href); return false;" target="_blank"><img border="0" src="images/options/a2.gif" width="83" height="57"></a>

POPUP.ASP
-------------
<%
dim image_name
image_name=Request.QueryString("image")
description=Request.QueryString("desc")
%>

<script language='javascript'>
var NS = (navigator.appName=="Netscape")?true:false;
function FitPic() {
iWidth = (NS)?window.innerWidth:document.body.clientWidth;
iHeight = (NS)?window.innerHeight:document.body.clientHeight;
iWidth = document.images[0].width - iWidth;
iHeight = document.images[0].height - iHeight;
window.resizeBy(iWidth, iHeight);
self.focus();
};
</script>

<body onload="FitPic();" topmargin="0" marginheight="0" leftmargin="0" marginwidth="0">
<img src="<%=image_name%>" border="0" alt="">
<font face="Verdana"><b><%=description%></b></font>

Works great,
thanks!


0
VirusMinusCommented:
Glad I could help.

Cheers,
-VM
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.