Alright, the code I have put together, let us not forget, I know little java, and this is peice together from trial/error/tutorials, and my wanting knowledge to use C++ into this for some ungodly reason. My problem is I cannot get the Image to show up as the picture. Anyone know a fix for that, or what I am doing wrong? <FONT onClick='openpicture("JamesAndAshlingHomecomming.jpg")'>James And Ashling</FONT> <SCRIPT LANGUAGE="JavaScript"> function openpicture(image) { var image; OpenWindow=window.open("", "newwin", "height=250, width=250, toolbar=no, scrollbars=no, menubar=no"); OpenWindow.document.write("<TITLE>Picutre Description</TITLE>") OpenWindow.document.write("<BODY BGCOLOR=#003366 TEXT=#CCCCFF LINK=#CCCCFF VLINK=#CCCCFF ALINK=#CCCCFF>") OpenWindow.document.write("<IMG SRC=image>") OpenWindow.document.write("<CENTER><FONT onClick='window.close()'> Click here to close </FONT></CENTER>") OpenWindow.document.write("</BODY>") OpenWindow.document.write("</HTML>") OpenWindow.document.close() self.name="main" }
For readability, I usually do something like: var Imagestring = "<IMG SRC=" + image; OpenWindow.document.write(Imagestring) The alternative (which you see much more frequently) is to do the plus bit to concatenate right inside the function call, I just find that less tidy.
Linear means like this: OpenWindow.document.write("<IMG SRC=" + image + ">"); if you don't want to declare a new variable also don't forget the ";" behind every line
When I click the text, I get: "Line: 0" "Error: Object expected" Anyone make sense of that? <FONT onClick='picture("JamesAndAshlingHomecomming")'>James And Ashling</FONT> <SCRIPT LANGUAGE="JavaScript"> function picture(image) { var Imagestring = "<IMG SRC=./images/" + image + ".jpg"; OpenWindow.document.write(Imagestring); OpenWindow=window.open("", "newwin", "height=250, width=250, toolbar=no, scrollbars=no, menubar=no"); OpenWindow.document.write("<TITLE>Picutre Description</TITLE>"); OpenWindow.document.write("<BODY BGCOLOR=#003366 TEXT=#CCCCFF LINK=#CCCCFF VLINK=#CCCCFF ALINK=#CCCCFF>"); OpenWindow.document.write(Imagestring); OpenWindow.document.write("<CENTER><FONT onClick='window.close()'> Click here to close </FONT></CENTER>"); OpenWindow.document.write("</BODY>"); OpenWindow.document.write("</HTML>"); OpenWindow.document.close(); }
change Code: OpenWindow.document.write(Imagestring); OpenWindow=window.open("", "newwin", "height=250, width=250, toolbar=no, scrollbars=no, menubar=no"); to Code: OpenWindow=window.open("", "newwin", "height=250, width=250, toolbar=no, scrollbars=no, menubar=no"); OpenWindow.document.write(Imagestring); Can't write into it until you've created it. cheers alastair
you sure works ok for me. you also need to put a closing '>' on the line Code: var Imagestring = "<IMG SRC=./images/" + image + ".jpg"; sample code at... http://www.19nine78.net/bit-tec/test.htm I changed the path from /images/ to /avatars/ so an image would show up on my server but other than that the code should work. let me know how you get on. cheers alastair
I figured it out, thanks. </SCRIPT> was missing there. Now my next task, making this thing auto detect picture height/width in pixels and adding like 20 to each size.
change this line: Code: var Imagestring = "<IMG SRC=./images/" + image + ".jpg>" to: Code: var Imagestring = "<IMG name=myImage onload=window.resizeTo(document.myImage.width,document.myImage.height) SRC=avatars/" + image + ".jpg>"; and adjust the 'src=' to suit your setup. cheers alastair