Files
Websites/Profice WebSite/scripts/login-test.js
2026-01-28 16:04:48 +01:00

48 lines
1.5 KiB
JavaScript

// Simple test script for login button
console.log('Login test script loaded');
// Clear any existing session that might cause redirect issues
localStorage.removeItem('userSession');
sessionStorage.removeItem('userSession');
console.log('Cleared any existing session data');
// Wait for DOM
document.addEventListener('DOMContentLoaded', function() {
console.log('DOM loaded in test script');
// Find login button
const loginBtn = document.getElementById('loginBtn');
console.log('Login button found:', !!loginBtn);
if (loginBtn) {
console.log('Login button element:', loginBtn);
// Determine correct path based on current location
const currentPath = window.location.pathname;
console.log('Current path:', currentPath);
let loginPath;
if (currentPath.includes('/sites/')) {
// Already in sites folder, use relative path
loginPath = 'login.html';
} else {
// In root folder, use sites/ prefix
loginPath = 'sites/login.html';
}
console.log('Login path will be:', loginPath);
// Direct onclick
loginBtn.onclick = function(e) {
e.preventDefault();
console.log('ONCLICK: Login button clicked!');
console.log('Navigating to:', loginPath);
window.location.href = loginPath;
};
console.log('Click handler attached');
} else {
console.error('Login button NOT FOUND');
}
});