aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes JavaScript is not running on IE8 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JavaScript is not running on IE8" Watch "JavaScript is not running on IE8" New topic
Author

JavaScript is not running on IE8

Faisal Fuad
Ranch Hand

Joined: Jul 05, 2011
Posts: 76

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

Joined: Jan 10, 2002
Posts: 60059
    
  65

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()?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Faisal Fuad
Ranch Hand

Joined: Jul 05, 2011
Posts: 76

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
Bartender

Joined: Oct 14, 2005
Posts: 18141
    
    8

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

Joined: Jan 10, 2002
Posts: 60059
    
  65

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

Joined: Jul 05, 2011
Posts: 76

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
Bartender

Joined: Oct 14, 2005
Posts: 18141
    
    8

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

Joined: Nov 08, 2001
Posts: 15376
    
    6
I would guess that foo.src = foo.src; is grabbing the image from the cache.

Eric
Faisal Fuad
Ranch Hand

Joined: Jul 05, 2011
Posts: 76

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaScript is not running on IE8
 
Similar Threads
Anchor Tag passing an input variable
jQuery tabs form validation is failing
session variable data lost or weirdness
Avoiding Site Breakage
Cannot view data in pop-up window in ascending order