so i have an iframe embedded that allows a golf student to login and view their lessons.
when you view on mobile the window for the iframe doesn’t fit the mobile.
is there a way i can install a button with link to website for login and hide it on desktop but have it visible on mobile. i can’t seem to get it work. i’m guessing if you hide an element it’s hidden on all devices. any other workaround suggestions?
thanks
owen
Hi Owen,
Welcome to the Wix Code forums.
You can use wix-window.formFactor to determine if the site is running on a mobile or desktop platform. Then just hide() or show() the element.
Have fun,
Yisrael
Thanks Yisrael. i know very little about coding. is there a tutorial that would help show me how to embed this onto page?
Just use the example in the wix-window.formFactor API. Something like this:
let formFactor = wixWindow.formFactor;
if(formFactor === "Desktop") {
$w("#myMobileOnlyElement").hide();
}
Good luck,
Yisrael
so in between the “” i should add the iframe code?
thanks
Substitute #myMobileOnlyElement with the name of the element you want to hide.
Hello y have the same problem .
when i read:
import wixWindow from ‘wix-window’;
let formFactor = wixWindow.formFactor;
if (formFactor === “Desktop”) {
$w(“#html2”).hide();
}
i have an error on the scrip
There was an error in your scriptThe element selector function (usually $w) cannot be used before the page is ready
Where is my error?
Thank you d’avance
Il faut attendre que la page soit prete:
$w.onReady(function() {
if(formFactor === "Desktop") $w("#html2").hide();
});