SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Apr 2004
    Location
    No Where
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I really need help with this please

    I'm desperate...I've searched google over and over again typing different queries and I've gone on many forums such as this one and I cannot find an answer to my question...

    I have a website with an english and a german part (english is my site and the german part is a friend webmaster's site...)

    I hate splash screens and I want it to appear once. I want the user to choose the language and then he will be automatically redirected to his choice instead of having to use the splash screen again.

    I know nothing about cookies nor Java programming...only HTML

    Does anyone have a pre-made script or something to help me?

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Prosis, Welcome to SitePoint Forums!

    This was a quickie - and I haven't tested it - but maybe it will be helpful.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Template</title>
    <meta name='author' content='Author' />
    <meta name='description' content='Description' />
    <meta name='keywords' content='Keywords' />
    <link rel='stylesheet' type='text/css' href=''>
    <style type='text/css'>
    </style>
    <script type='text/javascript' src=''></script>
    <script type='text/javascript'>
    window.onload = function()
    {
      var lang = xGetCookie('language');
      redirect(lang);
    }
    function setLanguage(lang)
    {
      xSetCookie('language', lang);
    }
    function redirect(lang)
    {
      var url;
      if (lang == 'german') {
        url = 'myGermanPage.html';
      }
      else if (lang == 'english') {
        url = 'myEnglishPage.html';
      }
      else {
        return;
      }
      if (location.replace) {
        location.replace(url);
      }
      else {
        location.href = url;
      }
    }
    // X, Cross-Browser.com DHTML Library, Licensed LGPL
    // cookie implementations based on code from Netscape Javascript Guide
    function xSetCookie(name, value, expire, path) {
      document.cookie = name + "=" + escape(value) + ((!expire) ? "" : ("; expires=" + expire.toGMTString())) + "; path=/";
    }
    function xGetCookie(name) {
      var value=null, search=name+"=";
      if (document.cookie.length > 0) {
        var offset = document.cookie.indexOf(search);
        if (offset != -1) {
          offset += search.length;
          var end = document.cookie.indexOf(";", offset);
          if (end == -1) end = document.cookie.length;
          value = unescape(document.cookie.substring(offset, end));
        }
      }
      return value;
    }
    </script>
    </head>
    <body>
    
    <p>Select your language:
      <a href='myEnglishPage.html' onclick="setLanguage('english')">English</a>,
      <a href='myGermanPage.html' onclick="setLanguage('german')">Deutsche</a>
    </p>
    
    </body>
    </html>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •