Connecting Tech Pros Worldwide Help | Site Map

Javascript Script Making and Reading Cookies For Users Language

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 20th, 2005, 11:23 AM
Jack Whitton
Guest
 
Posts: n/a
Default Javascript Script Making and Reading Cookies For Users Language

Hi
Im creating a website at the minute and I need some help with the
homepage. I want there to be 3 flags, English German and Spanish, and
when a user clicks on there flag I want them to be redirected to
en.html for english, de.html for german and es.html for spanish. I
also want a cookie to be dropped when they click on their flag so when
they return it automaticly refers them to the right website. Can
someone please help write this code as I am a complete novice at
JavaScript!
Please help. Thanks

  #2  
Old July 20th, 2005, 11:27 AM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
Default Re: Javascript Script Making and Reading Cookies For Users Language

Jack Whitton wrote:
[color=blue]
> I want there to be 3 flags, English German and Spanish, and
> when a user clicks on there flag I want them to be redirected to
> en.html for english, de.html for german and es.html for spanish.[/color]

You need no JavaScript and you want no flags for that:

http://www.cs.tut.fi/~jkorpela/flags.html

BTW: I suggest index.XX.html or index.html.XX, so you can use
Content Negotiation if supported.
[color=blue]
> I also want a cookie to be dropped when they click on their flag so
> when they return it automaticly refers them to the right website.[/color]

Client-side JavaScript can provide that:

<a href="en.html"
onclick="document.cookie = ...; location = this.href; return false;"[color=blue]
>en</a>[/color]

See
http://devedge.netscape.com/library/...t.html#1193577
for details.

But since client-side Scripting it can be disabled, you should prefer a
server-side solution. Make PHP scripts out of the documents, e.g., and use
those scripts to set the cookie.


PointedEars
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.