Forum Moderators: open

Message Too Old, No Replies

image in new window

image in new window

         

meanweaver

7:00 pm on Jun 30, 2004 (gmt 0)

10+ Year Member



I have been using some javascript code so that when an image is clicked it appears in a new window without scroll bars. I now want to use the script on multiple images on the same page. What do i have to change for this to be done. I have very little understanding of lavascript itself so please keep answers simpile(ish).
here is the code this in the head

<script language="javascript">
<!--
function openMywindow(){
open("images/school%20proof.JPG","PageName","scrollbars=0, width=492,height=305, top=5, left=5, title=School Proof").focus();

this in the body

<a href="javascript:openMywindow()"><font size="-2">Click TO Enlarge</font><img src="images/school%20proof.JPG" width="300" hspace="20" vspace="20" align="left"></a>

Regards Ian

randallxski

8:51 pm on Jun 30, 2004 (gmt 0)

10+ Year Member



Here's one way to do this. I modifed the script slightly to use variables for the image file name and image description:
<!-- this in the <head> -->
<script language="javascript">
<!--
function openMywindow(image,title){
open("images/" + image,title,"scrollbars=0,width=492,height=305,top=5,left=5").focus();
}
-->
</script>

I put the images in table cells to make them more readable. Just repeat everything between the <tr> and </tr> cell for each image (you may want 2-3 in each row, but you can modify that later). Modify the image file name in 2 places, and the image title once:

<!-- this in the body -->
<table>

<tr>
<td>
<a href="javascript:openMywindow('school%20proof.JPG','School Proof 1')">
<font size="-2">Click To Enlarge</font>
<br>
<img src="images/school%20proof.JPG" width="300" hspace="20" vspace="20" align="left"></a>
</td>
</tr>

<tr>
<td>
<a href="javascript:openMywindow('school%20proof2.JPG','School Proof 2')">
<font size="-2">Click To Enlarge</font>
<br>
<img src="images/school%20proof2.JPG" width="300" hspace="20" vspace="20" align="left"></a>
</td>
</tr>

</table>

meanweaver

1:57 pm on Jul 1, 2004 (gmt 0)

10+ Year Member



Thats excellent thankyou very much.

Regards Ian