Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery 'Object' is undefined when reference Jquery twice

Tags:

jquery

iframe

I have a asp.net page, in its header section I have the following:

<script type="text/javascript" src="scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.8.19.custom.min.js"></script>

And I also have:

<div id="dialog" title="Dialog Title">
    <iframe src="frameDemo.aspx" scrolling="no" style="border:0px" width="500"></iframe>
</div>

And in the frameDemo.aspx header section, I also have:

<script type="text/javascript" src="scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.8.19.custom.min.js"></script>

Every time I press the debug button, it open up IE and gives me an error which says:

Microsoft JScript runtime error: 'Object' is undefined

I press continue, and it pops up again and again about 5 to 6 times for the same error message. And then finally it shows the page and is working fine.

But if I copy the URL and open it in another browser, it doesn't show any error message. Or if I set Safari/Firefox as a debugging browser, the error message doesn't show up either. It looks like only using IE as the debugging browser will produce the error.

Also, if I remove the following from frameDemo.aspx page, the error doesn't show up as well:

<script type="text/javascript" src="scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.8.19.custom.min.js"></script>

So it looks like if I reference the JQuery twice in a sub-iframe page, and debug in IE browser I will get that error message.

Has anyone come across this issue? Thank you very much!

like image 483
Niusao Avatar asked Apr 16 '26 07:04

Niusao


1 Answers

If you have no control over the other instance of jQuery then consider using

http://api.jquery.com/jQuery.noConflict/

like image 116
Dave Hogan Avatar answered Apr 17 '26 19:04

Dave Hogan