Operatic shenanigans
I've got the following Javascript function in a page (basically, it provides a preview function for image file uploads for administrators to a site I'm working on. It works fine in Mozilla, IE and even Konqueror, but the image isn't displaying in the window that it opens, when viewed with Opera. Everything else works fine (although Opera doesn't support Accesskeys), but without an image, it's a but of a pointless window. Frustratingly, I find I cannot view source, either - resumably because the source is being dynamically written. I also notice that, although Mozilla works fine, i gives me an hourglass symbol the whole time the window is open - so I assume this feature is the result of shoddy markup, on my part.
<script language="JavaScript" type="text/javascript">
<!-- Displays a pop-up (VGA-sized) for previewing images for upload
function displayLocalFile (fileName) {
var url = 'file:///' + fileName;
if (document.layers && location.protocol.toLowerCase() != 'file:' && navigator.javaEnabled())
netscape.security.PrivilegeManager.enablePrivilege ('UniversalFileRead');
var newWindow = window.open ('', 'previewwin', 'width=640,height=480,top=20,left=20,menubar=no,to olbar=no,scrollbars=yes');
newWindow.document.open();
newWindow.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'
+ '<html><head><title>Admin :: Preview of Proposed Replacement Image</title></head><body>'
+ '<center><img src="' + url + '" alt="Preview of proposed replacement image" /><br />'
+ '<form><input type="button" accesskey="C" value="Close Window" '
+ 'onClick="javascript:window.close();"></form></center></body></html>');
}
//-->
</script>
It isn't critical (since it does function in some browsers, including the common one), but I'm not one to blame a browser, when my markup doesn't work in it, and so I'd like to know where I've messed up.
Dan
|