472,784 Members | 996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,784 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 1496
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
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.