473,410 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

Input field, Onchange and Nestcape.


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
2 1799


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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: lehmann | last post by:
Hello, I discovered that in a form with checkboxes input, if the checkboxe is not checked, not value is sent in my request by the browser (at least IE, I think it is ok in NS). But I my...
2
by: kie | last post by:
hello, when i create elements and want to assign events to them, i have realised that if the function assigned to that element has no parameters, then the parent node values can be attained. ...
9
by: Gary Holt | last post by:
We have a problem demonstrated by the following HTML document. To see the problem type HV in the first field then use the mouse cursor to click into the Staff code input box. You will find that...
1
by: John Pastrovick | last post by:
Is there a way to load an image locally (in the client) when a selection of a file is made using input type=file. The purpose is to allow selection of a file and put the image in the browser...
7
by: JW | last post by:
hello everybody I've got the following problem. I'm writing a form and I'm using javascript to validate fields (i.e. numeric, not blank). When my scripts detects an error I want it to put the...
12
by: Susan Cranford | last post by:
Please forgive, I have looked at so much info I can't figure out how to put it together even though I know it must be fairly simple. I have an array of input text boxes (txtDOBn) where n is...
1
by: julian.tklim | last post by:
Hi, I've got an input box with popup calendar (date picker) all generated using javascipt. Once a date is selected from the datepicker window, the date value is populated back to the input...
1
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.