473,326 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Redirection with Cookies

Hi there!

I have a big Problem with some javascript:
On a website, i want to paste some "confirm", if the
visitor's browserlanguage is not "de".
when he confirm, he'll be redirected to the english-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 Count = 0;
if (navigator.appName == 'Netscape')
{ var Language = navigator.language }
else {
var Language = navigator.browserLanguage
}
var cookies = document.cookie.split(/; /);
for(var i = 0; i < cookies.length; i++)
{
cookies[i] = cookies[i].split(/=/);
cookies[i][1] = unescape(cookies[i][1]);
if(cookies[i][0] == 'Count') Count = cookies[i][1];
if(cookies[i][0] == 'Language') Language = cookies[i][1];
if(cookies[i][0] == 'Benutzer') Benutzer = cookies[i][1];
}

//Here comes the Problem:
//if 1st time here (count = 0) AND language = de
//I tried a few methods but the script isn't working

if (Count = 0 && Language.indexOf('de') > -1)
{
var Benutzer=confirm ("Your " + navigator.appName + " Language
is " + Language + ".\n\Would you like to switch to the English
Version?\n\-Translated by Babelfish-")
if (Benutzer==true)
{
Benutzer = window.location="http://world.altavista.com/babelfish/trurl_load?url=http%3A%2F%2Fmembers.chello.at%2Fst efan.szeiler&lp=de_en";
}
else { Benutzer = window.location="#"; }
}

Count++;

//Expire of Cookies in 1 year

var Datum = new Date();
Datum.setFullYear(Datum.getFullYear() + 1);
var expires = "expires=" + Datum.toGMTString();

//Cookies write:

document.cookie = "Count=" + escape(Count) + "; " + expires;
document.cookie = "Language=" + escape(Language) + "; " + expires;
document.cookie = "Benutzer=" + escape(Benutzer) + "; " + expires;
// Ende -->
</script>
Jul 23 '05 #1
1 1523
JRS: In article <d8**************************@posting.google.com >,
dated Wed, 21 Jul 2004 00:51:10, seen in news:comp.lang.javascript, Karl
<an********@web.de> posted :

var Datum = new Date();
Datum.setFullYear(Datum.getFullYear() + 1);
var expires = "expires=" + Datum.toGMTString();


FullYear is not always available; why not use the shorter

Datum.setMonth(Datum.getMonth() + 12);
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> JL / RC : FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: TJ Talluto | last post by:
Hi, I'm using the curl functions in php to scrape the wan ip address from my home router (the router is an SMC product). This is a two step process: 1. post the password value to the login.htm...
52
by: Gerard M Foley | last post by:
Can one write a webpage which is not displayed but which simply redirects the user to another page without any action by the user? Sorry if this is simple, but I am sometimes simple myself. ...
1
by: Jason Williard | last post by:
I am trying to implement several website translations. In doing so, a cookie is set so upon return to the site, they are automatically redirected. If the language is set to something other than...
2
by: Mitul | last post by:
Hello friends. I have some problem while submitting page. The alert will popup and display following message. So Please help me as soon as possible. I am not able to submit the page due to this....
3
by: sconeek | last post by:
hi all, i am working on a web based java application. now i have this HTML page which gets refreshed every 2 seconds (using javascript). now i also want to redirect the user from this page to...
3
by: Advo | last post by:
is there any reason why i can view a page at work (which is on our server) yet when i view it online from the domain name (some pages are hosted, some are running off our server) i get the message:...
13
by: souissipro | last post by:
Hi, I have written a C program that does some of the functionalities mentionned in my previous topic posted some days ago. This shell should: 1- execute input commands from standard input,...
2
by: fReDiNi | last post by:
Hi, I have an strange problem with session variables. I have a site hosted in a local server. I have physic access to this server and its configuration.(apache, php,files...). I have external...
1
by: comp.lang.php | last post by:
require_once("/users/ppowell/web/php_global_vars.php"); if ($_GET) { // INITIALIZE VARS $fileID = @fopen("$userPath/xml/redirect.xml", 'r'); $stuff = @fread($fileID,...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.