user2046091
user2046091

Reputation: 399

IE throws JavaScript Error (Works on other browser)

I'm having a real problem with JavaScript scope in IE 7.

I have declared function at top of page like following

function close_fancy()
{
  $.fancybox.close();

}

called function on

<input type="reset" name="reset" id="button2" value="Close'" onclick="close_fancy();"/>

its working on all major browsers except IE-7 it throws following error

The value of the property 'close_fancy' is null or undefined, not a Function object

Please Help Me On This...

Upvotes: 2

Views: 127

Answers (2)

Spudley
Spudley

Reputation: 168803

Since you're using jQuery, you should be writing it in a jQuery style.

This means not using onclick= in the HTML code, but instead writing a $(elem).click() function, like so:

$('#button2').click(function() {
    $.fancybox.close();
}

You then don't need a separate close_fancy function at all.

As per normal with jQuery, this code should be placed in a javascript block at the foot of your page, or inside a $(document).ready() function.

Upvotes: 0

user1737842
user1737842

Reputation:

Try this:

parent.$.fancybox.close();

Upvotes: 1

Related Questions