开发者

I have one javascript error in my IE8 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.

开发者_如何学编程

Closed 8 years ago.

Improve this question

"Object doesn't support this property or method"

It's this line.

pthumb = $("#pthumb").attr("src");

Does anyone know why?


You have a javascript variable called "pthumb" and a DOM element with the id "pthumb", and IE's JS engine could be trying to use the wrong one.

If you have a function also called "pthumb" then IE could also be trying perform this action on the function object.

The last thing to try is to make sure you are using "var" when declaring "pthumb" in the Javascript. i.e.:

var pthumb = $("#pthumb").attr("src");


Are you ensuring the DOM is ready?

$(document).ready(function(){  

    //wrap your code in document-ready check

    pthumb = $("#pthumb").attr("src");  

});


you could double check the plain javascript method:

var jthumb= document.getElementById('pthumb').attributes['src'].value;
try{
pthumb = $("#pthumb").attr("src");
}
catch(er){
alert(er.message + '\n'+jthumb)
}

If you don't catch the error, the element is not yet ready.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜