Thank you for your reply ! All the code on the initial post was from the main page (masterPage as called by Wix).
Here is the code on the lightbox page to close it by pressing button6:
import wixWindow from 'wix-window';
$w.onReady(function () {
$w('#button6').onClick(function () {
wixWindow.lightbox.close("Website Redirect");
})
})
Here is the code on the masterPage:
import {fetch} from 'wix-fetch';
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");
}
let userConfirm = session.getItem("userConfirm")
if(userConfirm !== true) {
// 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");
}
});
}})
I moved the $w.onClick function after “onReady” but still have the same error.
I’m learning on the go, but I really don’t know what you mean by using String instead of Boolean… Could you tell me more?
Thank you so much for your help!