Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Image Pop-up Javascript Error
Index -> Web Design
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rar




PostPosted: 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 http://www.hypergurl.com/thumbnails.html

It is as follows:

code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Supplied by http://www.hypergurl.com --> function openindex() { var
OpenWindow=window.open("", "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'
border='no'></a>


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?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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

http://www.huddletogether.com/projects/lightbox2/
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Ultrahex




PostPosted: Mon May 17, 2010 8:35 pm   Post subject: Re: Image Pop-up Javascript Error

HTML:
<SCRIPT LANGUAGE="JavaScript">
function openindex() {
        var OpenWindow=window.open("", "newwin","height=318,width=402");
        OpenWindow.document.write("<img src='a.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;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).
rar




PostPosted: 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!
Display posts from previous:   
   Index -> Web Design
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: