Current location: Hot Scripts Forums » General Web Coding » JavaScript » Image preview not working in IE7.Please help


Image preview not working in IE7.Please help

Reply
  #1 (permalink)  
Old 10-03-07, 02:24 AM
subhasps8 subhasps8 is offline
Newbie Coder
 
Join Date: Jun 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Question Image preview not working in IE7.Please help

Hi,

I have an application that opens a file dialog. You can select an image and after that you can see it in a preview image tag.

The preview images on client side works fine in IE6, but not IE7.

This preview does not need postback to the server .

Can this script work in IE 7?

javascript Code:
  1. <script language="javascript"  type="text/javascript">
  2.       function ChangeLogo(obj)
  3.  
  4.         {
  5.  
  6.             if (obj != null)
  7.  
  8.             {
  9.  
  10.                 var img = document.getElementById("imgLogo");
  11.  
  12.                 if (img != null)
  13.  
  14.                 {
  15.  
  16.                     img.src = obj.value;
  17.  
  18.                 }
  19.  
  20.             }
  21.  
  22.         }
  23.  
  24.    </script>...
  25.  
  26. <asp:Image  ID="imgLogo"   BorderWidth="1px" BorderColor="CornflowerBlue" ImageUrl="~/images/empty_logo.jpg" Width="60px"  runat="server" />                                                                                                                                                                                                                                                                               
  27.  
  28. <asp:FileUpload   OnChange="ChangeLogo(this);"  BorderColor="CornflowerBlue"  ID="fuLogo" Width="170px" />

The code above is working in IE 6.But not in IE 7.


So used the code below.But the image is still not displayed in IE 7.

The code snippet I used is:

javascript Code:
  1. <script type="text/javascript" language="javascript">
  2.  
  3. function ChangeLogo(obj)
  4. {
  5.  
  6. document.getElementById("<%=imgPhoto.ClientID %>").style.visibility='visible';vbvbvbif (obj != null)
  7. {
  8.  
  9. var img = document.getElementById("<%=imgPhoto.ClientID %>");
  10.  
  11. if (img != null)
  12. {
  13.  
  14. alert(obj.value);
  15.  
  16.  
  17. img.setAttribute("ImageUrl",obj.value);
  18. }
  19.  
  20. }
  21.  
  22. }
  23.  
  24. </script>
  25.  
  26. <body>
  27.  
  28.  
  29.  
  30. <asp:Image ID="imgPhoto" runat="server" Width="100px" Height="100px" style="visibility:hidden" />
  31.  
  32. <asp:FileUpload ID="filePhoto" runat="server" onchange="javascript:ChangeLogo(this);" />
  33.  
  34. </body>

Then also image is not displyed.What shall i do?

I want to show image preview in my page.Please give a solution for this issue..

Thank You,
Subhashni Palanivel.

Last edited by Nico; 10-03-07 at 04:57 AM.
Reply With Quote
  #2 (permalink)  
Old 10-03-07, 05:02 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Seems more like a Javascript issue. Moving thread to Javascript.

And this line seems odd:
javascript Code:
  1. document.getElementById("<%=imgPhoto.ClientID %>").style.visibility='visible';vbvbvbif (obj != null)

The vbvbvbif (obj != null)

If should probably be just if (obj != null)
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image functions in php is not working in mozilla Murugesan PHP 1 12-02-06 04:15 AM
Image size function not working Jonhoo PHP 23 08-21-06 12:22 PM
Image Upload and Preview Script needed markimarkc Script Requests 1 02-19-06 10:48 AM
image swapping not working in ie6? sneakyimp JavaScript 2 04-18-05 09:18 AM
need help with upload image and getting image name to db mikewooten PHP 3 05-14-04 04:52 PM


All times are GMT -5. The time now is 11:31 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.