Click to See Complete Forum and Search --> : bet this is SOOOO SIMPLE


ppeettee
08-04-2003, 09:39 AM
Hi newbie here.
anyone spend a couple of seconds and tell me whats wrong with this?

<HTML>
<HEAD>
<TITLE>Family</TITLE>
<script language="JavaScript" type="text/JavaScript">
for (var i=1; i<200;i++)
{
this.document.write("<a onClick='newwin('"+i+".jpg')>");
this.document.write("<IMG SRC='thumb_"+i+".jpg' height=100>");
this.document.write("</a>");
};

function newwin(url)
{
pwidth=400;
pheight=400;
xpos=200;
ypos=200;
picwindow=window.open("","piccy",'width='+pwidth+',height='+pheight+',screenx='+xpos+',screeny='+ypos+',left='+xpos+',top='+ypos+',t oolbar=no,titlebar=no,directories=no,menubar=no,location=no,status=no,resizable=yes');
picwindow.document.write("<center>Click on image to close<a href='javascript:window.close()'><img src="+url+"></a>")
picwindow.document.close()
};
</script>

</HEAD>
<body bgcolor="#FFFFFF"></body>
</HTML>

rdoekes
08-04-2003, 10:36 AM
I think you want to have a list of thumbnail images, and if you click on an image it opens a new window with the full image.

1. your for loop should be in the body section of your html document.
2. the syntax for window.open is incorrect:
picwindow = window.open(url, "piccy" ,'width etc......');

Hope this helps,

-Rogier Doekes

ppeettee
08-05-2003, 06:13 AM
Thanks for that I put the for loop in the body of the HTML but no change in what happens.

It's not pointing to a url, I'm trying to make the script write a html page (first time I've dont this) I'm using picwindow.document.write to write the html, it displays all the images but comes up with a syntax error for each image on line 22 and nothing happens when i click on the thumbnails.

I think there's some syntax error in
this.document.write("<a onClick='newwin('"+i+".jpg')>"); and I'm just being daft

I'm getting the feeling i'm just going round this completely the wrong way.

Cheers

Pete.

Gollum
08-05-2003, 07:15 AM
No, you're not being daft, the problem as I see it is in that line. You've too many levels of nested quotes. Try this instead...

document.write("<a onClick=\"newwin('"+i+".gif')\">");

ppeettee
08-05-2003, 08:04 AM
that was it!
you, Gollum, are a true hero.

Thanks again.

Pete