PDA

Click to See Complete Forum and Search --> : JavaScript Window


Pino
Jun 17th, 2005, 09:57 AM
Ok i've built up a gallery for a client and i ahd each thumnail loading up ina seperate window. But he decided he wanted javascript windows.

Now then I'm a javascript N00b and dont really want tpo get into it but do need some help with this.


<SCRIPT LANGUAGE="JavaScript">
function show_photo(pFileName,pTitle,pCaption) {
photoWin = window.open( "", "Cerys Gallery", "width=600,height=450, status,scrollbars,resizable,screenX=20,screenY=40,left=20,top=40");
photoWin.document.write('<html><head><title>' + pTitle + '</title></head>');
photoWin.document.write('<BODY BGCOLOR=#000000 TEXT=#FFFFCC LINK=#33CCFF VLINK=#FF6666>');
photoWin.document.write('<center>');
photoWin.document.write('<font size=+3 face="arial,helvetica"><b>' + pCaption + '</b></font><br>');
photoWin.document.write('<img src="' + pFileName + '"><p>');
photoWin.document.write('<font face="arial,helvetica">');
photoWin.document.write('"' + pTitle + '"<br>');
photoWin.document.write('<p></font></body></html>');
photoWin.document.close();
if (navigator.appName.substring(0,8) == "Netscape") photoWin.focus();
}
</SCRIPT>


and i am trying to set a link of each picture file to load its picture/captiona dn title in this javascript widnow.


echo "<a href='javascript:show_photo(" . $path . "," . $title . "," $caption ")>";
echo "<img src='" . $path . "' width='100'></a></td>";


As we can see i'm mixing Php/Html/Javascript :)

This does nothing :( can anyone explain to me how to use the function above corrrctly?

Pino
Jun 17th, 2005, 03:33 PM
Anyone any thoughts? I'm stuck here and i have a client on my back :(

RobDog888
Jun 17th, 2005, 06:16 PM
You say it does nothing? No popup window?

This is a snippet of some of my js code for a popup window. Note that the parameters for the popup are in the format - scrollbars=False ....
function openPopWin(winURL, winWidth, winHeight, winScroll) {
var winOptions = 'menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=' + winScroll + ',resizable=yes,width=' + winWidth + ',height=' + winHeight;
popup = window.open(winURL, 'popup', winOptions);
}

RobDog888
Jun 17th, 2005, 06:25 PM
Oh ya, and I just noticed that your not using the escape character for your document.write code.
.document.write("<html><head><title>Loading Image, Please Wait...<\/title><\/head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 text='",imgWidth,imgHeight,"'><center><a href='#' onClick =javascript:window.close()><img src='",imgName,"' alt='Click to Close' border='0'><\/a><\/center><\/body><\/html>")

ALL
Jun 18th, 2005, 05:17 PM
just a little point (if you want it!)... you dont need to seperate the variables form the output, unless you use the single quote. also you can do a line return in an echo statement ;)
echo "<a href='javascript:show_photo(" . $path . "," . $title . "," $caption ")>";
echo "<img src='" . $path . "' width='100'></a></td>";
to:
echo "<a href='javascript:show_photo($path,$title,$caption)'>
<img src='$path' width='100'></a></td>";

just thought i'd let you know ;)

PS: you are missing your end single quote of the first line of that php code! (i added in the second snippit)