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 4130
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 NS won't
recognize it.
Can anyone tell me why...
|
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 functions. Works fine for IE
and Opera, doesn't...
|
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();
label.Width = 20;
label.Text = "Test";...
|
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
overflow:scrolling, a width an a height. This works very well in...
|
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
source path...';
I've been working on a...
|
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
every second and displaying how much a file...
|
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?
Reason I ask is that one of my current clients...
|
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 form doesn't move. Any work around? Thanks.
|
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 || e.pageY) {"
2) "document.getElementById()"...
|
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 and the other recently went to the new Leopard...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
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...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
|
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,...
|
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...
| |