Javascript Script Making and Reading Cookies For Users Language

J

Jack Whitton

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
 
T

Thomas 'PointedEars' Lahn

Jack said:
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.

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.
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.

Client-side JavaScript can provide that:

<a href="en.html"
onclick="document.cookie = ...; location = this.href; return false;"

See
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/document.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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top