Connecting Tech Pros Worldwide Forums | Help | Site Map

Toggle Image - Problem in IE

kiran
Guest
 
Posts: n/a
#1: Jul 23 '05
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";
}
}

Vincent van Beveren
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Toggle Image - Problem in IE


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.

kiran
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Toggle Image - Problem in IE


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
Vincent van Beveren
Guest
 
Posts: n/a
#4: Jul 23 '05

re: Toggle Image - Problem in IE


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

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

Grant Wagner
Guest
 
Posts: n/a
#5: Jul 23 '05

re: Toggle Image - Problem in IE


kiran wrote:
[color=blue]
> 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[/color]

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 <gwagner@agricoreunited.com>

* 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


Closed Thread