473,405 Members | 2,272 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,405 software developers and data experts.

Compatibility for Mozilla Firefox - for div tag

15
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.


Expand|Select|Wrap|Line Numbers
  1.  
  2. function showFile()
  3. {
  4.  
  5.  var f = document.acuploadfrm;
  6.  document.getElementById("imgdiv").innerHTML = "<img  src='"+f.imgfile.value+"' width=730>";
  7.     document.getElementById("imgdiv").style.display = 'block';
  8.  
  9.  
  10.  
  11. }
  12.  
  13.  

Can any one pls help me to solve this...
Nov 30 '07 #1
17 4130
acoder
16,027 Expert Mod 8TB
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.
Nov 30 '07 #2
Nithu25
15
But the same function is working fine in Internet Explorer. If the img src ..is the problem how it will work in IE?
Dec 3 '07 #3
Nithu25
15
ya...i got wat is specified in the reply..Thank You
Dec 3 '07 #4
acoder
16,027 Expert Mod 8TB
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.
Dec 3 '07 #5
Nithu25
15
Hi...
How to set the absolute path for the image (in the above situation) to make it display in the Mozilla Firefox browser?
Dec 4 '07 #6
Velhari
46
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
Dec 4 '07 #7
acoder
16,027 Expert Mod 8TB
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.
Dec 4 '07 #8
acoder
16,027 Expert Mod 8TB
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.
Dec 4 '07 #9
Nithu25
15
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.
Dec 5 '07 #10
acoder
16,027 Expert Mod 8TB
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.
Dec 5 '07 #11
Nithu25
15
Thank You for your reply.
Dec 7 '07 #12
Ferris
101 100+
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]
Dec 7 '07 #13
acoder
16,027 Expert Mod 8TB
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.
Dec 10 '07 #14
Ferris
101 100+
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!
Dec 10 '07 #15
acoder
16,027 Expert Mod 8TB
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.
Dec 11 '07 #16
Nithu25
15
Thank You all for your replies.
Dec 12 '07 #17
acoder
16,027 Expert Mod 8TB
You're welcome. Sorry, the problem can't be solved, but the security restrictions are there for good reason.
Dec 12 '07 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

26
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...
36
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...
5
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";...
1
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...
2
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...
9
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...
6
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...
34
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.
2
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()"...
57
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
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
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,...
0
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...
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...

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.