Lightbox to open only on mobile (not working)

Hi,

I would like a lightbox to display when viewing the website on a mobile to say “We recommend using a desktop to maximise your experience. To continue viewing our site on your mobile, close this window”

I have set up the lightbox in desktop view and added the following to site code…

$w.onReady(function () {
 if (wixWindow.formFactor === "Mobile") {
        wixWindow.openLightbox("mobileLightbox");
    }
});

However, the lightbox is not displaying when viewed on a mobile.

Any suggestions?

Thanks,
Rachel

Hi @rachelskuse ,

Here is a few tips:

  1. Please check that lightbox name is correct - same one that you see in the settings panel (in my case mobileBox )
  2. Please see that you did an import for wixWindow [ import wixWindow from ‘wix-window’;]
  3. In case that you want to show this lightbox on redirect to home/specific page - be sure that this part of code was added there, otherwise it should be added to SITE section.
  4. Disable the auto-display option

Please see if it helps.

Thanks.

Plus, if not done so already, make sure that you have read the support pages on it as it describes how to do it perfectly.
https://support.wix.com/en/article/corvid-tutorial-displaying-elements-in-mobile-only
https://support.wix.com/en/article/corvid-writing-code-that-only-runs-on-mobile-devices
https://www.wix.com/corvid/reference/draft/wix-window.html#formFactor

Thank you, I was using the name as specified in Property ID not in the settings panel so all working now :slight_smile: