开发者

JavaScript function doesn't work in IE?

I'm having a lot of problems with IE7/IE8 and Javascript/jQuery, which I don't have in Chrome or FireFox.

I have this Javascript function:

function ch开发者_StackOverflow社区angeImg(img,bla){
    $('#open_case').css("background-image", "url('"+img+"')");
    getIngo(bla);
    navigation_image(bla);
}

And this is my onclick function:

<div class="cImage" style="background-image:url('http://bla.com/images/this_image.jpg');" onclick="changeImg('http://bla.com/images/this_image.jpg','2');"></div>

But it's like the function isn't called at all, 'cause if I change the changeImg function to an alert function:

function changeImg(img,bla){
    alert('hi!');
}

It still doesn't work.

The only error IE7/IE8 gives is Expecting Object(roughly translated)

What am I doing wrong?

Thanks in advance!

[Edit:]

These are lines IE7/IE8 is pointing at;

<script type="text/javascript" src="Scripts/swfobject.js"></script>
<script type="application/javascript" language="javascript">
function clearText(textfield){
    if (textfield.defaultValue == textfield.value){
        textfield.value = '';
        $(textfield).css('color','#000000');
    }
}
function addText(textfield){
    if (textfield.value == ''){
        textfield.value = textfield.defaultValue;
        $(textfield).css('color','#999999');
    }
}


If the error is object expected. Then try this

Change your

<script type="application/javascript" language="javascript">

To

<script type="text/javascript">


Is there a reason you're using javascript here? It looks like you're changing the image on a navigation item? You could just just the CSS :hover classes. Regardless, using onmouseover isn't really the "proper" way to be handling this sort of thing in javascript, if you really cannot use just CSS, at the very least look into handling the mouse over envent properly in jQuery.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜