473,574 Members | 2,582 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript Issue With Firefox

Joe
I'm trying to create an image preview function so that my users can
preview images before they upload them. I've got my example working
locally on both Firefox and IE, and from the webserver in IE. However,
when I try to access the example via a webserver and Firefox, it
doesn't work. Any help with this would be greatly appreciated.

(Code listed below:)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<script language=Javasc ript>
<!--
function previewImage()
{
var previewImage = document.f.colo rtheme.value;
var spaceMatch = / /gi;
var slashMatch = /\\/gi;
previewImage = previewImage.re place(spaceMatc h, "%20");
previewImage = previewImage.re place(slashMatc h, "/");
previewImage = "file:///" + previewImage;
document.getEle mentById('PREVI EW').src = previewImage;
return false;
}
//-->
</script>

<html>
<head>
<title>PREVIE W-IMAGE (UPDATED-1123)</title>
</head>

<body>
<h5>PREVIEW IMAGE onChange</h5>
<table border="1" bgcolor="gold">
<tr>
<td>
<form method="post" name="f" id="f"
action="form_dr opdown_image_se lect_rmk_UNIVER SAL.html">
<!--
visit our website: http://www.angdatingdaan.org --- really cool
email me: ro****@linuxmai l.org
-->
Select image:<br>
<input type="file" name="picture" maxlength="1024 " value=""
onchange="previ ewImage()" id="colortheme" >

</center>
</form>
</td>
<td valign="center" width="300" align="center"> <img
src="http://images.animatio nfactory.com/animations/animals/rodents/mouse_quiet_shh/mouse_quiet_shh _sm_nwm.gif"
border="0" id="PREVIEW" alt="preview image"/></td>
</tr>
</table>
</body>
</html>
Jul 23 '05 #1
9 1823
Joe wrote:
I'm trying to create an image preview function so that my users can
preview images before they upload them. I've got my example working
locally on both Firefox and IE, and from the webserver in IE. However,
when I try to access the example via a webserver and Firefox, it
doesn't work. Any help with this would be greatly appreciated.

(Code listed below:)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<script language=Javasc ript>
<!--
function previewImage()
{
var previewImage = document.f.colo rtheme.value;
var spaceMatch = / /gi;
var slashMatch = /\\/gi;
previewImage = previewImage.re place(spaceMatc h, "%20");
previewImage = previewImage.re place(slashMatc h, "/");
previewImage = "file:///" + previewImage;


You set a local file with the "file" protocol. This should only work
locally. As a web application should not access to local files. If this
will work in IE it might be a security risk.

Instead, set the full path to your file on the web server or better - as
it might work on both your local drive and your server - define a
relative path and don't use backslashes.

Daniel
Jul 23 '05 #2
Joe
Thanks for the quick response Daniel. Let me see if I'm understanding
correctly... So basically what you're saying is there should be no way
for my end user to be able to see the picture they are uploading
before they actually go ahead and upload it?

Daniel Kirsch <Iw************ *****@gmx.de> wrote in message news:<co******* ******@news.t-online.com>...
Joe wrote:
I'm trying to create an image preview function so that my users can
preview images before they upload them. I've got my example working
locally on both Firefox and IE, and from the webserver in IE. However,
when I try to access the example via a webserver and Firefox, it
doesn't work. Any help with this would be greatly appreciated.

(Code listed below:)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<script language=Javasc ript>
<!--
function previewImage()
{
var previewImage = document.f.colo rtheme.value;
var spaceMatch = / /gi;
var slashMatch = /\\/gi;
previewImage = previewImage.re place(spaceMatc h, "%20");
previewImage = previewImage.re place(slashMatc h, "/");
previewImage = "file:///" + previewImage;


You set a local file with the "file" protocol. This should only work
locally. As a web application should not access to local files. If this
will work in IE it might be a security risk.

Instead, set the full path to your file on the web server or better - as
it might work on both your local drive and your server - define a
relative path and don't use backslashes.

Daniel

Jul 23 '05 #3
"Joe" <ka******@gmail .com> wrote in message
news:f4******** *************** **@posting.goog le.com...
I'm trying to create an image preview function so that my users can
preview images before they upload them. I've got my example working
locally on both Firefox and IE, and from the webserver in IE. However,
when I try to access the example via a webserver and Firefox, it
doesn't work. Any help with this would be greatly appreciated.

(Code listed below:)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<script language=Javasc ript>
<!--
function previewImage()
{
var previewImage = document.f.colo rtheme.value;
var spaceMatch = / /gi;
var slashMatch = /\\/gi;
previewImage = previewImage.re place(spaceMatc h, "%20");
previewImage = previewImage.re place(slashMatc h, "/");
previewImage = "file:///" + previewImage;
document.getEle mentById('PREVI EW').src = previewImage;
return false;
}
//-->
</script>

<html>
<head>
<title>PREVIE W-IMAGE (UPDATED-1123)</title>
</head>

<body>
<h5>PREVIEW IMAGE onChange</h5>
<table border="1" bgcolor="gold">
<tr>
<td>
<form method="post" name="f" id="f"
action="form_dr opdown_image_se lect_rmk_UNIVER SAL.html">
<!--
visit our website: http://www.angdatingdaan.org --- really cool
email me: ro****@linuxmai l.org
-->
Select image:<br>
<input type="file" name="picture" maxlength="1024 " value=""
onchange="previ ewImage()" id="colortheme" >

</center>
</form>
</td>
<td valign="center" width="300" align="center"> <img
src="http://images.animatio nfactory.com/animations/animals/rodents/mouse_qui
et_shh/mouse_quiet_shh _sm_nwm.gif" border="0" id="PREVIEW" alt="preview image"/></td>
</tr>
</table>
</body>
</html>


"<input type=file" does not support "onchange".

Also, you shouldn't assign the same name to a function and a variable.

You could invoke it via a button; try this:

<html>
<head>
<title>preview. htm</title>
<script type="text/javascript">
function previewImage() {
var previewValue = document.f.colo rtheme.value;
// var spaceMatch = / /gi;
// var slashMatch = /\\/gi;
previewValue = previewValue.re place(/ /gi,"%20");
previewValue = previewValue.re place(/\\/gi,"/");
previewValue = "file:///" + previewValue;
alert(previewVa lue);
document.getEle mentById('PREVI EW').src = previewValue;
return false;
}
</script>
</head>
<body>
<h5>PREVIEW IMAGE onClick</h5>
<table border="1" bgcolor="gold">
<tr>
<td>
<form action="form_dr opdown_image_se lect_rmk_UNIVER SAL.html"
method="post" name="f">
Select image:<br>
<input type="file" name="picture" id="colortheme" >
<input type="button" vlaue="Preview" onclick="previe wImage()">
</form>
</td>
<td valign="center" width="300" align="center">
<img
src="http://images.animatio nfactory.com/animations/animals/rodents/mouse_qui
et_shh/mouse_quiet_shh _sm_nwm.gif" border="1" id="PREVIEW" alt="preview
image"/>
</td>
</tr>
</table>
</body>
</html>
Jul 23 '05 #4
On Fri, 26 Nov 2004 16:30:54 GMT, McKirahan <Ne**@McKirahan .com> wrote:

[snip]
function previewImage()
{
var previewImage = document.f.colo rtheme.value;

[snip]
Also, you shouldn't assign the same name to a function and a variable.


Problems will only occur if the scopes clash. As it is, the variable is in
a different scope. The only adverse effect is that code would be unable to
access the "outer" identifier, but that isn't a concern here.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #5
Joe
Thanks for the tips. However, I went ahead and tried your code. It
seems to suffer from the exact same problems as my code. Namely, it
works fine when accessed from the desktop. However, if you stick it on
a webserver it just doesn't work. Does it work for you?

"McKirahan" <Ne**@McKirahan .com> wrote in message news:<2TIpd.396 163$wV.210142@a ttbi_s54>...
"Joe" <ka******@gmail .com> wrote in message
news:f4******** *************** **@posting.goog le.com...
I'm trying to create an image preview function so that my users can
preview images before they upload them. I've got my example working
locally on both Firefox and IE, and from the webserver in IE. However,
when I try to access the example via a webserver and Firefox, it
doesn't work. Any help with this would be greatly appreciated.

(Code listed below:)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<script language=Javasc ript>
<!--
function previewImage()
{
var previewImage = document.f.colo rtheme.value;
var spaceMatch = / /gi;
var slashMatch = /\\/gi;
previewImage = previewImage.re place(spaceMatc h, "%20");
previewImage = previewImage.re place(slashMatc h, "/");
previewImage = "file:///" + previewImage;
document.getEle mentById('PREVI EW').src = previewImage;
return false;
}
//-->
</script>

<html>
<head>
<title>PREVIE W-IMAGE (UPDATED-1123)</title>
</head>

<body>
<h5>PREVIEW IMAGE onChange</h5>
<table border="1" bgcolor="gold">
<tr>
<td>
<form method="post" name="f" id="f"
action="form_dr opdown_image_se lect_rmk_UNIVER SAL.html">
<!--
visit our website: http://www.angdatingdaan.org --- really cool
email me: ro****@linuxmai l.org
-->
Select image:<br>
<input type="file" name="picture" maxlength="1024 " value=""
onchange="previ ewImage()" id="colortheme" >

</center>
</form>
</td>
<td valign="center" width="300" align="center"> <img

src="http://images.animatio nfactory.com/animations/animals/rodents/mouse_qui
et_shh/mouse_quiet_shh _sm_nwm.gif"
border="0" id="PREVIEW" alt="preview image"/></td>
</tr>
</table>
</body>
</html>


"<input type=file" does not support "onchange".

Also, you shouldn't assign the same name to a function and a variable.

You could invoke it via a button; try this:

<html>
<head>
<title>preview. htm</title>
<script type="text/javascript">
function previewImage() {
var previewValue = document.f.colo rtheme.value;
// var spaceMatch = / /gi;
// var slashMatch = /\\/gi;
previewValue = previewValue.re place(/ /gi,"%20");
previewValue = previewValue.re place(/\\/gi,"/");
previewValue = "file:///" + previewValue;
alert(previewVa lue);
document.getEle mentById('PREVI EW').src = previewValue;
return false;
}
</script>
</head>
<body>
<h5>PREVIEW IMAGE onClick</h5>
<table border="1" bgcolor="gold">
<tr>
<td>
<form action="form_dr opdown_image_se lect_rmk_UNIVER SAL.html"
method="post" name="f">
Select image:<br>
<input type="file" name="picture" id="colortheme" >
<input type="button" vlaue="Preview" onclick="previe wImage()">
</form>
</td>
<td valign="center" width="300" align="center">
<img
src="http://images.animatio nfactory.com/animations/animals/rodents/mouse_qui
et_shh/mouse_quiet_shh _sm_nwm.gif" border="1" id="PREVIEW" alt="preview
image"/>
</td>
</tr>
</table>
</body>
</html>

Jul 23 '05 #6
"Joe" <ka******@gmail .com> wrote in message
news:f4******** *************** **@posting.goog le.com...
Thanks for the tips. However, I went ahead and tried your code. It
seems to suffer from the exact same problems as my code. Namely, it
works fine when accessed from the desktop. However, if you stick it on
a webserver it just doesn't work. Does it work for you?


[snip]

It worked for me (IE 5.5) via:
http://localhost/preview.htm
Jul 23 '05 #7
Joe
Oh yeah, sorry. It works fine for me in IE, but so does my original
code. I'm only having problems with FireFox.

"McKirahan" <Ne**@McKirahan .com> wrote in message news:<fc0qd.572 797$mD.120678@a ttbi_s02>...
"Joe" <ka******@gmail .com> wrote in message
news:f4******** *************** **@posting.goog le.com...
Thanks for the tips. However, I went ahead and tried your code. It
seems to suffer from the exact same problems as my code. Namely, it
works fine when accessed from the desktop. However, if you stick it on
a webserver it just doesn't work. Does it work for you?


[snip]

It worked for me (IE 5.5) via:
http://localhost/preview.htm

Jul 23 '05 #8
"Joe" <ka******@gmail .com> wrote in message
news:f4******** *************** **@posting.goog le.com...
Oh yeah, sorry. It works fine for me in IE, but so does my original
code. I'm only having problems with FireFox.

"McKirahan" <Ne**@McKirahan .com> wrote in message

news:<fc0qd.572 797$mD.120678@a ttbi_s02>...
"Joe" <ka******@gmail .com> wrote in message
news:f4******** *************** **@posting.goog le.com...
Thanks for the tips. However, I went ahead and tried your code. It
seems to suffer from the exact same problems as my code. Namely, it
works fine when accessed from the desktop. However, if you stick it on
a webserver it just doesn't work. Does it work for you?


[snip]

It worked for me (IE 5.5) via:
http://localhost/preview.htm


Sorry, I forgot the original Subject line!
Jul 23 '05 #9
Joe wrote:
Thanks for the quick response Daniel. Let me see if I'm understanding
correctly... So basically what you're saying is there should be no way
for my end user to be able to see the picture they are uploading
before they actually go ahead and upload it?


Probably not. You may access local files with additional privileges, but
the confirmation popups usually frighten people.

Daniel
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2178
by: Keyser | last post by:
On most my pages, I use Javascript to play a sound. It works fine in Netscape 4.7, Netscape 7.2, Firefox 1.0, IE5 and IE6 using Windows98 as the operating system. However, using WindowsXP as the operating system, the entire Netscape 7.2 browser and Firefox 1.0 browser shuts down when I try to use the Back button on these pages. Is there...
5
2151
by: Roger Withnell | last post by:
This is a framed webpage with the navigation bar in "NavBar" and the main window in "Main". When opening a new page in "Main" from "NavBar" with: function OpenFrameWindow(src) { var NewWindow = window.open(src, "Main"); NewWindow.focus(); }
7
9590
by: Coder | last post by:
Hi I have the following code in java script, it is not giving proper output in FIREFOX but running fine in IE... can anybody help me out to make this run in FIREFOX . <script language="JavaScript"> var cntlName; var eleTarget = document.getElementById('hiding'); function showOrHide(){
8
1919
by: Matt Kruse | last post by:
http://news.zdnet.com/2100-1009_22-6121608.html Hackers claim zero-day flaw in Firefox 09 / 30 / 06 | By Joris Evers SAN DIEGO--The open-source Firefox Web browser is critically flawed in the way it handles JavaScript, two hackers said Saturday afternoon. An attacker could commandeer a computer running the browser simply by crafting...
7
1451
by: Adam | last post by:
Hello All, I have run into a JS / CSS layout issue in IE, and I can't for the life of me figure out what's going on. Basically, I have one DIV that is expanding beyond the bounds of the containing DIV, and I've literally spent hours trying to find the problem. It appears to be somehow tied to the scrollbars, but again, I'm not sure. The...
15
2244
by: Phlip | last post by:
Javascripters: I have an outer page and an inner iframe. The outer page calculates some javascript, and wants the inner frame to run it. The inner frame should hit a page on the same (private) web server, so this is not a cross-site scripting attack. But I would prefer not to taint the target page with any extra logic to do this. (I will if...
6
5822
by: scotty | last post by:
I have a script that loops through an existing table list and prepares each href element node to trigger a function when an image is clicked. The function that will be run passes a property value to the function upon clicking. The property value is one of the attributes defined for each respective href in the property list. In IE and...
4
6036
by: iamaporkaholic | last post by:
The main page of the site has this script which determines the language settings of the OS. This works fine for IE but not for firefox. Is there any other codes which i have to insert to make sure Firefox would be able to load it? <script type="text/javascript"> function detectlang() { var lang=navigator.userLanguage var...
15
1634
by: qwarehouse | last post by:
Hello, I am having an issue with javascript in firefox. On this URL, there should be a menu displayed above a dashed line. Works ok in IE6 & 7 but no menu displays in firefox. Any sugestions? http://classifiedads.officeresalesolutions.com/TesT.html Thanks! Tim
3
1450
by: Nightcrawler | last post by:
I recently moved over a bunch of functionality to use javascript and webservices. I ran into the issue where a webservice taking longer than 10 seconds to respond will cause Firefox to throw a fit and show the "script has stopped responding" warning. Is there a way around this? What can possible be done so that firefox keeps the connection...
0
7808
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8063
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8243
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7822
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6456
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5626
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5302
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3742
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.