Computer Science Canada

Image Pop-up Javascript Error

Author:  rar [ Mon May 17, 2010 8:17 pm ]
Post subject:  Image Pop-up Javascript Error

I am trying to use some HTML code from HyperGurl (you may or may not be familiar with it) to add an element to my page where you click on a thumbnail for a picture and it opens a small window with the full size image.
I found the code at

It is as follows:

<!-- Supplied by --> function openindex() { var"", "newwin","height=318,width=402");
OpenWindow.document.write("<img src='sunflower.jpg'>") OpenWindow.document.write("<br>")
OpenWindow.document.write("<center><a href='javascript&#058;self.close()'
target='_self'>Close</a></center>") } </SCRIPT> <a
href="javascript&#058;openindex()" target="_self"><img src='sunflower2.jpg'

I used a debugger from IE 8 and it tells me it's missing a semi-colon. So I added one at the position they indicated, then it says missing object or something along those lines...can anyone see what's wrong with this code? It'd be extremely helpful...I know it's not the best way to learn by taking code like this from someone else's site but it's all I can do at the moment. But I'm stuck and I can't find the error in this code. Can someone help?

Author:  Tony [ Mon May 17, 2010 8:29 pm ]
Post subject:  RE:Image Pop-up Javascript Error

Uhh.... pop-ups are a bad idea. Let me introduce you to Lightbox

Author:  Ultrahex [ Mon May 17, 2010 8:35 pm ]
Post subject:  Re: Image Pop-up Javascript Error

function openindex() {
        var"", "newwin","height=318,width=402");
        OpenWindow.document.write("<img src='a.jpg'>");
        OpenWindow.document.write("<center><a href='javascript&#058;self.close();' target='_self'>Close</a></center>");
<a href="javascript&#058;self.openindex();" target="_self"><img src='b.jpg' border='no'></a>

works fine for me, i would recommend putting semicolons after end of commands, if you don't then all commands must be on different lines (this may be your problem, also I'm not sure if the different lines thing is cross browser compatible).

Author:  rar [ Mon May 17, 2010 9:11 pm ]
Post subject:  Re: Image Pop-up Javascript Error

I was able to get Lightbox working on the site.
Thanks very much for the info!