Handling iframes


#1

I have been having issues with 3rd party iframes lately. since they have the same structure as a standard page and since they raise similiar events I had a bug in which DOM manipulation were starting to impact the iframe.
Now recognizing iframe is straight forward but the problem is that also the app-creator operates within iframe. so I had to distinguish between the cases. now I am relying on the document.referrer to know it is an app-creator iframe (www.cloudflare.com) but it is not a very robust solution.
I think it would be for the best if you could expose that information, like you do with INSTALL_ID and preview state.
Would love to hear if there is a better solution if missed.


#2

Would it help to look at the window.top or the window.self objects? They both have a .location object that might be useful.


#3

Thx @sixcorners,
Indeed I was looking into that option and eventually went with document.referrer.
But the problem remains: how do yo distinguish between a case where the iframe is what you are in the app-creator site vs an iframe of the host site. I ended up using the URI, which could of course change.


#4


INSTALL_ID === “preview”?


#5

Thx @sixcorners.
Install I’d eq preview even in cases where the host site has already iframes.
I need to ensure it doesn’t treat the iframe as regular page and manipulates its dom unless of course the iframe is the one created in the app-creator page (the default one where you edit the settings).
Does it make sense?