K
Karl Gralowetz
Hello, Scriptmasters!
I have a big Problem with some Javascript:
One a website, i want to paste some "confirm" there, if the
visitor's browserlanguage is not "de".
when he confirm, he'll be redirected to the translation of this page.
to store this information, because it's ugly to ask on every single
visit, if he want to switch to the translation.
but i can't find out, why the script isn't working.
i please you to look at the source and answer me, if you have some
solution(s).
thanks, karl!
<SCRIPT LANGUAGE="JavaScript">
<!--
var expDays = 100;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (reisefotos) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" +
exp.toGMTString();
}
var favorite = GetCookie('reisefotos');
if (navigator.appName == 'Netscape')
var language = navigator.language
else
var language = navigator.browserLanguage
if (favorite != null && language.indexOf('it') > -1) {
SetCookie('reisefotos', this.name, exp);
}
if (favorite != null && language.indexOf('fr') > -1) {
var abfrage = confirm ("Ton " + navigator.appName + " langue est le "
+ language + ".\n\Voudrais-tu changer à la version
française?\n\-Traduction Babelfish-")
if (abfrage)
SetCookie('reisefotos', this.name, exp)
window.location="http://www.yahoo.fr"
}
else {
var abfrage = confirm ("Your " + navigator.appName + " Language is " +
language + ".\n\Would you like to switch to the English
Version?\n\-Translated by Babelfish-")
if (abfrage)
SetCookie('reisefotos', this.name, exp)
window.location="http://www.yahoo.com"
}
}
// End -->
</script>
I have a big Problem with some Javascript:
One a website, i want to paste some "confirm" there, if the
visitor's browserlanguage is not "de".
when he confirm, he'll be redirected to the translation of this page.
to store this information, because it's ugly to ask on every single
visit, if he want to switch to the translation.
but i can't find out, why the script isn't working.
i please you to look at the source and answer me, if you have some
solution(s).
thanks, karl!
<SCRIPT LANGUAGE="JavaScript">
<!--
var expDays = 100;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (reisefotos) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" +
exp.toGMTString();
}
var favorite = GetCookie('reisefotos');
if (navigator.appName == 'Netscape')
var language = navigator.language
else
var language = navigator.browserLanguage
if (favorite != null && language.indexOf('it') > -1) {
SetCookie('reisefotos', this.name, exp);
}
if (favorite != null && language.indexOf('fr') > -1) {
var abfrage = confirm ("Ton " + navigator.appName + " langue est le "
+ language + ".\n\Voudrais-tu changer à la version
française?\n\-Traduction Babelfish-")
if (abfrage)
SetCookie('reisefotos', this.name, exp)
window.location="http://www.yahoo.fr"
}
else {
var abfrage = confirm ("Your " + navigator.appName + " Language is " +
language + ".\n\Would you like to switch to the English
Version?\n\-Translated by Babelfish-")
if (abfrage)
SetCookie('reisefotos', this.name, exp)
window.location="http://www.yahoo.com"
}
}
// End -->
</script>