How to fix "Error: Object doesn't support this property or method" javascript error in Internet Explorer?
On this page with captcha demo:
http://www.tutorialcadet.com/demo/ajaxform/
the captcha image is not refreshing (when clicking on the image) in internet explorer. In firefox. chrome, opera it works fine.
It throws in explorer this popu up error:
Line: 155
Error: Object doesn't support this property or method
Then when I check the source code in explorer I see this on line 155:
<td><div id="captchaimage"><a href="SITE_BASE/register/" id="refreshimg" onclick="re开发者_如何学编程freshimg(); return false;" title="Click to refresh image"><img src="captcha/image.php?1311183335" alt="Captcha image" width="132" height="46" align="left" /></a></div></td>
Then when I click on the image again, another error popup shows up:
Line: 1
Error: Object doesn't support this property or method
When I view the source code I see a ?blank row? on the first row. Here is the screen what I mean by blank first row:
http://i54.tinypic.com/23ves1j.jpg
Any suggestion how to solve this? This happens only in internet explorer. I am currently using 9. Is this some kind of internet explorer bug or?
None of the JS files define the method refreshimg()
, hence the error.
Also captcha.js already has the code to handle the captcha.
Remove the refreshimage();
part from the onclick
of the #refreshimg anchor.
The anchor element should now look like:
<a href="SITE_BASE/register/" id="refreshimg" onclick="return false;" title="Click to refresh image">
<img src="captcha/image.php?1311183335" alt="Captcha image" width="132" height="46" align="left" />
</a>
Take out onclick="refreshimg()"
. That function is not defined anywhere and you don't really need that as the click event is already handled in http://www.tutorialcadet.com/demo/ajaxform/js/captcha.js
精彩评论