mardi 19 mars 2019

Show div based on variable (t/f) jade

I'm trying to check whether a page is in an iframe, and show divs accordingly.

In the page I have:

script.
  var iframeCheck = (self !== top);
  console.log(iframeCheck);

So far, when I load the page (not in an iframe), it logs "false" and when I'm loading the page in an iframe, it logs "true".

Where I'm running into trouble:

In my html (jade), I have the condition:

if iframeCheck
  a.button#showIfIframeOnly(href="") Show if iFrame only
else
  a.button#showIfNotIframeOnly(href="") Show if not in iFrame

It is showing the 'else' portion in both instances (page in iFrame and page not in iFrame).

I understand I'm probably syntaxing it wrong, but the Jade docs suck for this.

Why is it logging correctly, but displaying the wrong div?

Aucun commentaire:

Enregistrer un commentaire