@jonatandor35 THANK YOU SO MUCH!!! Problem solved !! ![]()
“Website Redirect” is the name of the lightbox.
Here is my final code, which is working perfectly:
Lightbox code:
import wixWindow from 'wix-window';
import {session} from "wix-storage";
$w.onReady(function () {
$w('#button6').onClick(function () {
session.setItem("userConfirm", "true");
wixWindow.lightbox.close("Website Redirect");
})
})
MasterPage code:
import {fetch} from 'wix-fetch';
import wixWindow from 'wix-window';
import {session} from "wix-storage";
$w.onReady(function () {
let userConfirm = session.getItem("userConfirm")
if(!userConfirm) {
// Fetching the user's location details
fetch('https://ipapi . co/json', {
method: 'get'
})
// Check if the request was successful
.then((httpResponse) => {
if (httpResponse.ok) {
return httpResponse.json();
}
})
.then((json) => {
// Set the user's countryCode as a const
const loc = json.country_code;
/* Check if country code is of Canada */
if(loc !== "CA"){
wixWindow.openLightbox("Website Redirect");
}
});
}})
Thank you for your time, it’s much appreciated ! ![]()