Best Practice: using jQuery within an iframe
CASE 1: once when using fancybox, i was not able to get the following code to work within an iframe.(yes i tried all the flavours related to the following code. see here [i have also replied to this thread] )
paren开发者_开发百科t.$.fancybox.close();
Finally I solved this problem by removing the main jquery file(jquery-1.5.2.min.js) from within the iframe.
CASE 2: in another page of the same project, the same fancybox(iframe) was saying $ is not defined.
Now, I solved this problem by adding the main jquery file(jquery-1.5.2.min.js) inside the iframe.
The problem i am facing now: $.fancybox.resize wont work for this iframe!(i strongly believe its cuz of the main jquery(jquery-1.5.2.min.js) i am including inside the iframe.)
This is confusing to me. I searched for issues when using jquery in iframes. some say there is no problem having another jquery inside the iframe. most ppl dont seem to have problems? cuz i was not able to find many related questions.
- Please tell me what is going wrong here. Something i need to take care of when using jquery within iframes?.
- Also please refer me to some resources i need to be looking up to handle these kinds of problems. like related to iframes? or iframes and javascript, scope related problems? etc?
Note:
1. these iframes are working correctly when individually accessed with a jquery-1.5.2.min.js included at the top. 2. My environment : windows xp | firefox 3.6.22 | jquery 1.5.2 | fancybox 1.3.4Have you thought it might be a bug in jquery? After all, you are using an old version. Maybe you should download Jquery 1.6.4, try it, and post back here if you're still having problems.
精彩评论