Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Toggle Image - Problem in IE

Reply
Thread Tools

Toggle Image - Problem in IE

 
 
kiran
Guest
Posts: n/a
 
      06-03-2004
Hi All

I am using the below function to change an image. I have checked in IE
and its working properly if seen locally on my system.

If the same is inserted in a jsp file and accessed from server, image
is toggled but it is not visible.

If we right click on the image and select 'Show Picture' it is
displayed.
Weird IE problem!!!! Anyone has solutions for this.

Kiran Makam


function toggleImg(name){
var obj = document.images[name];
var src = obj.src.toLowerCase();

if(src.indexOf("yes") != -1){
obj.src = "images/no.gif";
obj.alt = "Collapse";
}else{
obj.src = "images/yes.gif";
obj.alt = "Expand";
}
}
 
Reply With Quote
 
 
 
 
Vincent van Beveren
Guest
Posts: n/a
 
      06-03-2004
Thats weird,

I don't know why it goes wrong, but maybe preloading the images might
help. In the header, put the following code:

<SCRIPT LANGUAGE="JavaScript">
imYes = new Image();
imYes.src = 'images/yes.gif';
imNo = new Image();
imNo.src = 'images/no.gif';
</SCRIPT>

You're sure those images are the correct filenames? Did you check for
upper & lowcase? might be sensetive to that.

 
Reply With Quote
 
 
 
 
kiran
Guest
Posts: n/a
 
      06-04-2004
Thanks Beveren.

I have preloaded the images, still the problem persists. I checked
browser cache after the page is loaded, preloading is working fine.

If i try the function in a static page on my system, it works; when it
is added to a jsp file and accessed from server images refuses to show
up!!!!!

Kiran
 
Reply With Quote
 
Vincent van Beveren
Guest
Posts: n/a
 
      06-04-2004
> If i try the function in a static page on my system, it works; when it
> is added to a jsp file and accessed from server images refuses to show
> up!!!!!


I have no idea. Sorry. It should indeed work.

 
Reply With Quote
 
Grant Wagner
Guest
Posts: n/a
 
      06-04-2004
kiran wrote:

> Thanks Beveren.
>
> I have preloaded the images, still the problem persists. I checked
> browser cache after the page is loaded, preloading is working fine.
>
> If i try the function in a static page on my system, it works; when it
> is added to a jsp file and accessed from server images refuses to show
> up!!!!!
>
> Kiran


Check the source the browser is seeing. It's most likely that when the JSP
outputs the client-side JavaScript, you are losing quotation marks
somewhere along the way.

--
| Grant Wagner <>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
image toggle problem in accordion menu neetu Javascript 1 10-08-2009 08:45 PM
Simple Toggle checkbox function on IMAGE click ameshkin Javascript 4 07-22-2008 06:37 PM
how to toggle images when one clicks a image/ link Madame Blablavatsky Javascript 2 09-05-2005 02:48 PM
Image Toggle =?Utf-8?B?c2lhag==?= ASP .Net 1 05-04-2005 09:37 PM
toggle image with onLoad event Brian Javascript 2 03-30-2005 12:27 PM



Advertisments