472,344 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,344 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 4002
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...
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...
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();...
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...
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...
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...
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?...
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...
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...
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...
0
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...
0
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...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
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...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
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. ...
0
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...
0
hi
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...
0
Oralloy
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...

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.