By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,700 Members | 1,512 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,700 IT Pros & Developers. It's quick & easy.

Input field, Onchange and Nestcape.

P: n/a

I would like to preview an image before uploading. This code works fin
on IE but not on Netscape.
Does anyone know a work around for this one.

Code
-------------------
<script language="JavaScript" type="text/JavaScript">
function preview(thisImg,thisObj)
{

var filename = "";
var nothing = "";
filename = "file:\/\/"+thisObj.value;

var fileExtension = filename.substring(filename.lastIndexOf(".")+1);
if (fileExtension == "jpg" || fileExtension == "jpeg" || fileExtension == "gif")
{ thisImg.src="file:\/\/"+thisObj.value; }

else
alert ("Only jpg, jpeg and gif files are allowed."); }
}
</script>
<form name="form2" method="post" enctype="multipart/form-data" action="">
<img src="../images/icon_default.gif" name="myimga" width=100 height=80 border=0>

<INPUT NAME="upfile" TYPE="file" SIZE="80" ONchange="preview(myimga,upfile);">
<br>
<INPUT NAME="upload" TYPE="submit" VALUE="Upload">

</form
-------------------
----
miart

Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


miarte wrote:
I would like to preview an image before uploading. This code works fine
on IE but not on Netscape.
If that is Netscape 4 then you are not able to achieve that with later
4.something versions as a security hole was fixed by disallowing any
file: url access from pages loaded via HTTP.
Does anyone know a work around for this one.

Code:
--------------------
<script language="JavaScript" type="text/JavaScript">
function preview(thisImg,thisObj)
{

var filename = "";
var nothing = "";
filename = "file:\/\/"+thisObj.value;

var fileExtension = filename.substring(filename.lastIndexOf(".")+1);
if (fileExtension == "jpg" || fileExtension == "jpeg" || fileExtension == "gif")
{ thisImg.src="file:\/\/"+thisObj.value; }


Try there slashes
"file:///" + thisObj.value
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

P: n/a
"miarte" <mi***********@mail.forum4designers.com> wrote in message
news:mi***********@mail.forum4designers.com...
<snip>
forum4designers.com is a bad place to read comp.lang.javascript from
because their presentation of the group garbles the Usenet posts it is
derived from. Removing significant formatting, omitting sections and
adding text and white space that was not part of the original posts to
Usenet. And they only report a fraction of the posts made to the
group, giving an incomplete and inaccurate representation of the group.

In addition, the posting mechanism used by forum4designers.com fails
to properly implement RFC 1036 (Standard for Interchange of USENET
Messages), and in a way that is likely to result in confusion as to
conversational flow and intended respondee for anyone using genuine
Usenet software.

forum4designers.com is also a bad pace to ask javascript questions
from because their misrepresentation of the group, combined with
deliberate deceptions about the nature of the service that they
provide, have resulted in a level of resentment of
forum4designers.com that will negatively impact on anyone who decides
to associate themselves with that web site.

But being aware that forum4designers.com may not report posts made in
response to questions asked from there, and will actively
modify/distort any responses they do show, potential responders may
consider it a waste of there time to put any effort into responding to
posts originating from forum4designers.com even if they have no
attitude towards that site.

Many other sites provide superior web-based access to Usenet, and
often without distortion or omission, including groups.google.com
(who also provide extensive and flexible archive searching
facilities). But the best method of reading and posting to
comp.lang.javascript is through a news server via (standards
conforming) newsreader software.

Richard.
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.