[thelist] js popup images
John Corry
webshot at members.evolt.org
Tue Apr 23 19:09:01 CDT 2002
> If you happen to have access to PHP (or other server
> side language), you could write just one page that can
> include any image you want.
+100 this approach.
Using JavaScript to do this kind of thing is like walking without feet
compared to PHP (or some similar server side tool)
But if you MUST use js...
You could set up a function that generates a window's code on the fly...so
all you pass the function is the image's src, width, height and alt (and the
title of the new page, name of image, name of window...if desired).
Here's some code from my vault from a few years ago.
<script>
function openWindow(winX, winY, pic, newPageTitle) {
picWindow =
window.open('','picWin','width='+winX+',height='+winY+',toolbar=no,location=
no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no')
picWindow.focus() // Puts focus onto new window
if (window.picWindow) {
// write this code into it
var pictureCode = "<html><head><title>"+newPageTitle+"</title></head>\n"
pictureCode += "<body style=\"border: 0; margin: 0; padding: 0;
padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;
margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0;
background-color: #ffffff;\" leftmargin=\"0\" topmargin=\"0\"
marginheight=\"0\" marginwidth=\"0\" onload=\"window.focus();\">\n"
pictureCode += "<div>\n"
pictureCode += "<img src=\""+pic+"\"
width=\""+winX+"\"height=\""+winY+"\">\n"
pictureCode += "</div>\n"
pictureCode += "</body>\n"
pictureCode += "</html>"
picWindow.document.open ()
picWindow.document.write (pictureCode)
picWindow.document.close ()
}
}
</script>
hth,
John
More information about the thelist
mailing list