Does an IFRAME with a higher jQuery affect in any way the jQuery
behaviour of the parent HTML page?
As answered by @RGraham, by itself this will cause no conflict and they can happily co-exist as they belong to different browsing contexts.
However, theoretically there may be edge cases where your usage may affect it.
Consider a scenario where both your iframe
sources are in the same domain (perhaps different apps which you want to seamlessly surface). Say, your parent app references older version of jQuery and the child app references a newer version. Now, you can call methods on the parent version from your child. Perhaps a use-case where you cannot change anything in the parent app, but want to just use method calls from the child. In such a case, you have to be careful not to end up calling a defunct method on the parent.
For example,
Parent (Referencing older version of jQuery)
<html>
<head><script src="jquery-1.4.2.min.js"></script></head>
<body>
<h1>Parent</h1>
<input id="chk" type="checkbox">
<iframe src="child.html"></iframe>
</body>
</html>
Child (Referencing newer version of jQuery)
<html>
<head>
<script src="jquery-2.1.1.min.js"></script>
<script>
(function($) {
console.log("Attr: " + parent.$("#chk").attr("checked"));
console.log("Prop from child: " + $("#chk", parent.document).prop("checked"));
console.log("Prop from parent: " + parent.$("#chk").prop("checked"));
} (window.jQuery));
</script>
</head>
<body>
<h1>Child</h1>
</body>
</html>
Result:
Attr: false
Prop from child: false
Uncaught TypeError: parent.$(...).prop is not a function
As you can see, that the last test will throw up. This is because the method prop
is not available with the older version.
In short, you have to be careful to avoid such edge cases and use the document content context rather than the Javascript context.