Click to See Complete Forum and Search --> : open new window when thumbnail is clicked and disable right click in new window


Dallasjmoore
03-22-2004, 05:01 PM
Well, I have a large photo gallery and need to make it easily accesible (hopefully without having to insert a lot code for every image.) How can I make new window pop up when a thumbnail is clicked, resize it to fit the image size, and disable right click in the new window to try to help protect copywritten pics. Please help!

steelersfan88
03-22-2004, 05:09 PM
Try something like this:<script type="text/javascript">

function openWin(source, cap, H, W) {
// open window
newWin=window.open("", "newWin", "height="+ H +",width="+ W +",toolbar=no,scrollbars=no,menubar=no");
// write to window
newWin.document.write("<html><TITLE>"+ cap +"</TITLE>")
// get this on one line
newWin.document.write("<img src='"+ source +"' width='"+ W +"' height='"+ H +"' style='position:absolute;left:0;top:0'>")
newWin.document.write("<script> \n")
newWin.document.write("document.onselectstart = new Function(\"return false\"); \n")
newWin.document.write("document.oncontextmenu = new Function(\"return false\"); \n")
newWin.document.write("</s")
newWin.document.write("cript></html>")
// focus to window and close writing to it
newWin.focus()
newWin.document.close()
self.name="main"
}

</script>Then to your images, add the following:<img ...... onclick="openWin(this.src,'Caption for picture','width of pic','height of pic')">Note that the caption must be enclosed in quotes, the others should not be.

Dallasjmoore
03-22-2004, 05:39 PM
Well the thumbnail opens a new window and disables the right click, but it doesn't resize and the picture displays in the origional window. I might be doing something wrong. Let me know

<script type="text/javascript">

function openWin(source, cap, H, W) {
// open window
newWin=window.open("", "newWin", "height="+ H +",width="+ W +",toolbar=no,scrollbars=no,menubar=no");
// write to window
newWin.document.write("<html><TITLE>"+ cap +"</TITLE>")
// get this on one line
newWin.document.write("<img src='"+ source +"' width='"+ W +"' height='"+ H +"' style='position:absolute;left:0;top:0'>")
newWin.document.write("<script> \n")
newWin.document.write("document.onselectstart = new Function(\"return false\"); \n")
newWin.document.write("document.oncontextmenu = new Function(\"return false\"); \n")
newWin.document.write("</s")
newWin.document.write("cript></html>")
// focus to window and close writing to it
newWin.focus()
newWin.document.close()
self.name="main"
}

</script>

<p><center>
<a href="images/biglou-02.jpg">
<img src="images/gallery/small/01.jpg" onclick="openWin(this.src,'Big Lou','width of pic','height of pic')" width="72" height="100">
</a>

steelersfan88
03-22-2004, 06:51 PM
you didn't change the width of pic or height of pic in your picture's onclick attribute. this is the size of the window your want.

when two pictures are clicked, if you want them to open in dif't windows (code now does same), change to:window.open("", "_blank",...)Also, change to the following:window.open("", "...",config="...")