Forum Moderators: open
function ncdisplay_image(imagename) {
PreView = window.open("", "Preview", "toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=0,resizable=0,copyhistory=0,width=670,height=500");
PreView.document.open();
PreView.document.write('<script type="text/javascript"language="javascript" src="http://www.lifescapephoto.com/copywrt.js">');
PreView.document.write('<\/script>');
PreView.document.write('<META HTTP-EQUIV=imagetoolbar CONTENT=no>');
PreView.document.write("<HTML><HEAD>");
PreView.document.write("<TITLE>LifeScape Photography</TITLE>");
PreView.document.write("</HEAD><BODY onLoad='trap()' BGCOLOR=333333 TEXT=000000>");
PreView.document.write("<CENTER>");
PreView.document.write("<IMG HSPACE=0 VSPACE=0 " +
"SRC='" + imagename + "'>");
PreView.document.write("</CENTER>");
PreView.document.write("</BODY></HTML>");
PreView.document.close();
}
Also, I think each line of code writes immediately - I don't think it gets stored until document.close() happens. So if I were you I'd build a string, then write the whole string at once.
I believe Purple Martin's suggestion of using innerHTML has merit, though it can probably also be done a little easier with an ID on the body element, then using getElementById to change the CSS background property.
Quotes is a convoluted issue but this is a basic example:
onclick="myFunc('var1')" is okay, never onclick="myFunc("var1")".
This is okay on a document write :
document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">'
+'<html><head><title>Title stuff</title>'
+'<link rel="stylesheet" type="text/css" href="myCSS.css" media="print">')
To place quotes within a text string inside declaration escape them as in \' or \" (\ is the escape character).
Your line:
PreView.document.write("<IMG HSPACE=0 VSPACE=0 " +
"SRC='" + imagename + "'>");
might work better as "src=\"" + imagename + "\">");