inital-release
This commit is contained in:
@@ -3,14 +3,22 @@
|
|||||||
// Check if we're already on the correct page
|
// Check if we're already on the correct page
|
||||||
const currentPage = window.location.pathname.split('/').pop() || 'index.html'
|
const currentPage = window.location.pathname.split('/').pop() || 'index.html'
|
||||||
|
|
||||||
|
// Check if we've already redirected (prevent infinite loops)
|
||||||
|
const hasRedirected = sessionStorage.getItem('hasRedirected')
|
||||||
|
if (hasRedirected) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Detect mobile device
|
// Detect mobile device
|
||||||
const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
|
const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
|
||||||
|| window.innerWidth < 768
|
|| window.innerWidth < 768
|
||||||
|
|
||||||
// Only redirect if needed and not in an infinite loop
|
// Only redirect if needed
|
||||||
if (isMobile && !currentPage.includes('mobile.html')) {
|
if (isMobile && currentPage !== 'mobile.html') {
|
||||||
|
sessionStorage.setItem('hasRedirected', 'true')
|
||||||
window.location.href = 'mobile.html'
|
window.location.href = 'mobile.html'
|
||||||
} else if (!isMobile && currentPage.includes('mobile.html')) {
|
} else if (!isMobile && currentPage === 'mobile.html') {
|
||||||
|
sessionStorage.setItem('hasRedirected', 'true')
|
||||||
window.location.href = 'index.html'
|
window.location.href = 'index.html'
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|||||||
Reference in New Issue
Block a user