I need to redirect new visitor to a splash page created with joomla article.
I used this script:
<script type="text/javascript">
function redirect() {
var thecookie = readCookie('doRedirect');
if (!thecookie) {
window.location = 'prehome';
}
}
function createCookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
} else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
window.onload = function() {
redirect();
createCookie('doRedirect', 'true', '999');
}
</script>
I copied this script in theme.php
of the template.
It also works if I add the script in a module and publish it.
But for some seconds the homepage is shown before redirecting to the splash page.
Is there a script to prevent the showing the homepage before splash page?
And, is there a script to apply to my .htaccess
file?