Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaScript is not running on IE8

 
Faisal Fuad
Ranch Hand
Posts: 83
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone...I would like to refresh one specific form field by JavaScript. I wrote the following code and which is running absolutely fine with Chrome but IE8. Hearing that "getElementById" is not working on IE8 like the way it is in other browsers. And here I have to use IE8....Please help me to resolve this issue.

In my JSP page, I have this following field which I need to refresh:



And the following JS I tried before </HEAD>:

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read ItDoesntWorkIsUseless. The tell us what is happening.

How do you know it isn't "working"?

What diagnostic steps have you taken to conclude that the problem is with getElementById()?
 
Faisal Fuad
Ranch Hand
Posts: 83
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Bear...ok...i will not say "it isn't working" any more ok....No doubt that i know very less about JS and so asking all those stupid type questions. Now is there any way you can help me to resolve this issue Sir?

Oh by the way, while i was facing this problem, read something related to "getElementById and IE8" in a blog. Let me share the URL with you. May be they are also stupid but at least you and this forum can help them and me (in between) by showing path nicely

http://snowulf.com/2011/02/14/document-getelementbyid-not-working-in-ie8/

Best wishes
 
Paul Clapham
Sheriff
Posts: 21126
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best way to get your problem resolved is to describe it. What do you expect that code to do? What does it do instead?

(By the way I read that blog entry and what it talks about isn't related to your problem.)
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You still have not answered my questions. We're more than eager to help, but we need more information than you've provided.
 
Faisal Fuad
Ranch Hand
Posts: 83
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't take me negative....this simple thing is taking my whole time...and so looking for help. Ok what i am trying to do here is to target a particular form field which ID is "captcha". As you can see from the following two lines.....i added an image called "captcha_reload.gif" in line-2 and from there trying to call a JS function which will then refresh my target ID "captcha" from line-1.



I am doing this because line-1 is also having an image through "src" and that image is connected with a servlet. So my logic is, if i can refresh the "src" everytime then everytime i can call the servlet which will populate a new captcha image for me.

Hope this will help you both to understand my situation. Thanks
 
Paul Clapham
Sheriff
Posts: 21126
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Faisal Fuad wrote:Please don't take me negative....this simple thing is taking my whole time...and so looking for help.

Of course. That's what this forum is for. So don't take us to be negative when we try to make the process work for you.

Your Javascript function has just two lines. To me the second line looked a bit suspicious, but you seem to have decided already that the first line is the source of the problem. However you don't have any evidence for that, or at least you haven't shown us any. So I think your first step should be to start at the beginning, with no assumptions. Debug the two lines and see what happens differently in the different browsers.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would guess that foo.src = foo.src; is grabbing the image from the cache.

Eric
 
Faisal Fuad
Ranch Hand
Posts: 83
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys....a very sweet thing I have learned while solving my problem. Let me share the solution.

After reading all of your replies and hints (specially Eric's one), I started focusing on browser caching stuff...and found a great solution in this following blog:
http://www.ultramegatech.com/blog/2008/12/reloading-images-using-javascript/

So I just altered my image source based on different timestamp in my code and that worked awesome for my case. My code is now as follows:



Thank you so much to you all. And sorry Bear for the other day...I was bit lost Hope you won't mind. Bye
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic