Hi,
I am using div tag for displaying an uploaded image. On change of 'browse' button, a function called showFile () will be called. The image to be uploaded is displayed in the div tag named "imgdiv".This works fine using IE.But in firefox, the image is not displayed. If MAC OS with Safari browser is used, its displaying a 'question mark' instead of image. -
-
function showFile()
-
{
-
-
var f = document.acuploadfrm;
-
document.getElementById("imgdiv").innerHTML = "<img src='"+f.imgfile.value+"' width=730>";
-
document.getElementById("imgdiv").style.display = 'block';
-
-
-
-
}
-
-
Can any one pls help me to solve this...
17 4002
Welcome to TSDN!
The problem is not with the div tag, but with the image source. It's a local file, so JavaScript can't access it.
But the same function is working fine in Internet Explorer. If the img src ..is the problem how it will work in IE?
ya...i got wat is specified in the reply..Thank You
But the same function is working fine in Internet Explorer. If the img src ..is the problem how it will work in IE?
IE will display local images, other browsers won't.
Hi...
How to set the absolute path for the image (in the above situation) to make it display in the Mozilla Firefox browser?
Hi,
To display image in firefox, you have to proceed the following things in your browser before run that program.
In the address bar type, about:config
In filter option you have to type, security.checkloaduri
It will give the 'preference name' Double click that option and change the value to False
close the browser once and run your program, it will works fine.
Thanks,
Velhari
Hi...
How to set the absolute path for the image (in the above situation) to make it display in the Mozilla Firefox browser?
It's not about absolute and relative paths. Image files from the local hard disk cannot be accessed and therefore will not display.
To display image in firefox, you have to proceed the following things in your browser before run that program.
In the address bar type, about:config
In filter option you have to type, security.checkloaduri
It will give the 'preference name' Double click that option and change the value to False
close the browser once and run your program, it will works fine.
This may well work, but it would only work on a per-user basis. Each user would have to change their settings.
Thank You for Replies.
Hope that you undersood the requirement. The user should be able to upload image and that image selected in the browse file is displayed inside div tag.Onchange of the browser file the above given javascript function is called.
Do you mean that this is not possible in this way? If so, kindly provide me a solution how i can do this.
It's not about absolute and relative paths. Image files from the local hard disk cannot be accessed and therefore will not display.
Do you mean that this is not possible in this way? If so, kindly provide me a solution how i can do this.
Is this for an application used in a controlled user environment? If you can be sure of the settings, you may change the settings to allow the image preview to display, otherwise besides actually uploading the file and displaying the uploaded file (which sort of defeats the purpose), there's no other way.
Thank You for your reply.
Hi
Here's the solution.
If you want to show local images in firefox,you should use file protocal to visit it,not just give the image path. You code is:
<img src="C:\Photo\Photo1.jpg" />
it is fine in IE,but not fine in Firefox. So,change it into this:
<img src="file:///C:/Photo/Photo1.jpg" />
it OK!
OK,I write a sample code for you. I think it will solve your problem.
[HTML]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript">
function showFile(){
var imgSrc = document.getElementById("imgfile").value;
if (imgSrc!=""){
imgSrc = imgSrc.replace(/\\/g,"/");
imgSrc = "file:///" + imgSrc;
//alert (imgSrc);
document.getElementById("imgdiv").innerHTML = "<img src='"+imgSrc+"' />";
}
}
</script>
</head>
<body>
<div id="imgdiv" style="width:300px; height:300px; border:1px solid;"></div>
<input type="file" id="imgfile" onchange="showFile();" />
</body>
</html>
[/HTML]
Hi
Here's the solution.
If you want to show local images in firefox,you should use file protocal to visit it,not just give the image path.
No, I don't think that will work.
Try it online. If it does work, maybe you've changed the default settings.
No, I don't think that will work.
Try it online. If it does work, maybe you've changed the default settings.
Yes, you are right. I tried it online,and it doesn't work.
Thank you so much!
No problem. There is a setting you can change to make it work, but then everyone would have to change it which wouldn't be feasible.
Thank You all for your replies.
You're welcome. Sorry, the problem can't be solved, but the security restrictions are there for good reason.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Roger Desparois |
last post by:
Hi,
I need help : I found the simplest and most precise way to open and close
submenu layers. it works perfectly with IE, but for some odd reason...
|
by: Simon Wigzell |
last post by:
I have the following in my webpage:
<body onresize=CenterIt(); onMouseMove=mouseCheck(event);>
CenterIt and mouseCheck are my own javascript...
|
by: BJ |
last post by:
Hi,
I add label and text box fields dynamically in code using C# and ASP.NET. I
set the width of the label using:
Label label = new Label();...
|
by: Goffin |
last post by:
Hey
I have an asp.net datagrid width a scrollbar. This scrollbar is placed
using a div-tag around the grid with a style property...
|
by: Jason S |
last post by:
Is there a list of which browsers allow DHTML to create new <img>
elements? e.g.
var img = document.createElement('img'); img.src = '...some image...
|
by: Simon Wigzell |
last post by:
I have a little asp progress bar window that I open up with javascript,
sized and located, all the extras turned off. It works by refreshing itself...
|
by: Mark Rae |
last post by:
Hi,
I realise that this post isn't ABSOLUTELY to do with ASP.NET, but can anyone
please confirm whether pixels are different on Windows and Macs?...
|
by: Simon Wigzell |
last post by:
document...focus() will scroll the form to move the
specified text field into view on everything I have tried it with except
Safari on the MAC. The...
|
by: Serena |
last post by:
I have a problem whit this script. It is compatible with IE but isn't with
Firefox.
The error are:
1) "e has no properties" at----- "if(e.pageX...
|
by: HEX |
last post by:
Have a site under development which works with both IE and Mozilla Firefox.
Three MAC users accessed site and two have a small problem with one page...
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the...
| |