Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 26th, 2003, 05:41 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.