0

Here is the scenario:

My website (which uses jQuery) grabs the full UI of other websites (including their JS libraries) in order to modify them on the fly (with their approbation, of course).

From what I understand from How to avoid conflict between two version of Jquery library? , you need to apply the jQuery.noConflict() on the external jQuery as well, but in my case this couldn't be done because I can't write onto the external code.

So, how do I avoid conflicts in this scenario?

Community
  • 1
  • 1
majimekun
  • 210
  • 2
  • 10
  • How do you grab other website content? – A. Wolff May 24 '15 at 11:21
  • You would have to use `jQuery.noConflict()` on your code, not the code you're loading from the other site. – Barmar May 24 '15 at 11:24
  • @Barmar What if OP is loading more than one other website containing jQuery? – A. Wolff May 24 '15 at 11:26
  • In general, trying to load another site directly into your own page is going to cause lots of problems. What if they have element IDs or classes that conflict with yours? This is what iframes are for, they run each page in their own environment. – Barmar May 24 '15 at 11:29
  • @Barmar Really? I thought the jQuery.noConflict() had to be present on both sites. If you can confirm, I'll give a try. – majimekun May 25 '15 at 01:19
  • @A.Wolff I will be loading only one external website into mine. So, in the end, a maximum of two jQuery libraries. – majimekun May 25 '15 at 01:21
  • @Barmar For this particular project, iframes can't be used and I won't use IDs anyway (but I will use name/structure restricted classes) – majimekun May 25 '15 at 01:25
  • See http://stackoverflow.com/questions/1566595/can-i-use-multiple-versions-of-jquery-on-the-same-page/1566644#1566644. While you can use `jQuery.noConflict` in both scripts, you don't need to. Just call it at the beginning of your script, and make your own local variable that refers to jQuery. – Barmar May 25 '15 at 01:40

0 Answers0