当前位置: 动力学知识库 > 问答 > 编程问答 >

Can I load JQuery twice using iFrame?

问题描述:

Can someone who have JQuery experience have a look at my following description and give me some advice:

Default.aspx: This page has the JQuery reference at its section.

LoginControl.aspx: This page also has JQuery reference at its section.

In Default.aspx, there is a

So when Default.aspx is open, it loads the JQuery.js library and when the iFrame is open, it will load the JQuery second time because LoginControl.aspx loads it am I correct??

I am not sure if this will cause problem or its normal? two Reference will be load into different scope ? will they conflict potentially??

I don't know other solutions, I have to use the JQuery library in both aspx pages, if I don't include the reference in the LoginControl.aspx, then I can't use JQuery, it give me error.

At the moment it looks find with having Jquery in both pages' header section, but I am not sure if this is OK?? for all the browsers??

Thank you!

网友答案:

I am not sure if this will cause problem or its normal? two Reference will be load into different scope ? will they conflict potentially?

This is normal. The libraries will operate within their own scopes.

网友答案:

You could actually clone the original jQuery object by, for example:

window.$ = parent.window.$;

Furthermore, it is also possible to use in the embedded frame another (version) jQuery, the scope is differen, it's up to you if you want the user to execute two http request for actually one file!

Edit: Changed it to a better version of cloning it.

分享给朋友:
您可能感兴趣的文章:
随机阅读: