chrometweaks.org

How does this whole iPage web host thing work?

Click Here To View All Answers...


My 1st question is: How does this whole iPage web host thing work? Looking forward for any response. Another quick question... I would like the start page of my iPage site to be dependable of the favorita langage of the browser of the user, like this:.

Index.html:.

If favouritelangage=es (spanish) then.

Load page index-es.html.

Else.

Load page index-uk.html.

Endif.

This would probably depend on the type of brouwser used (IE, NS etc). Also in the IE I have seen that the user can select many types of Spanish (es-ar, es-bo, etc) how can you deal with this..

Thanks for your help!.

Hanno..

Comments (22)

I'm stumped. I'm not so sure what is the answer to your question. I'll do some Googling and get back to you if I bump into an anything. You should email the people at iPage as they probably could answer your iPage question..

Comment #1

Netscape uses the.

Navigator.language.

Property, whilst Internet Explorer uses.

Navigator.userLanguage.

And.

Navigator.systemLanguage.

..

Language codes are the ISO639 codes (en, es, fr etc.) but Netscape 6 and IE also append the ISO3166 country codes (us, au, dk etc.) to give en-us, es-mx, fr-be etc...

Comment #2

Thanks guys,.

I will try your code! (Don't worry Goldilocks; I will keep the option for the users to make their own choice in case the language setting on there system is not as they want it {like in an internet cafe etc})..

Hanno..

Comment #3

Hi Jon,.

I have added the following script in file.

Http://www.xcalak.info/test.html.

:.

<script language="JavaScript">.

Var tongue = (navigator.language || navigator.userLanguage).

Tongue = tongue.substring(0,2) // just the first 2 chars.

Var newPage = "";.

Switch (tongue) {.

Case "es" : newPage = "test-es.html";.

Break;.

Case !"es" : newPage = "test-uk.html";.

Break;.

}.

If (newPage) window.location.replace(newPage);.

</script>.

The language of my IE is on es-mx but there is no action to to to the page test-es.html. I am not farmiliar with Java, however I don't see any error messages..

Any idea what's wrong?.

Thanks,.

Hanno..

Comment #4

Don't use the ! in the case statement as I don't think this is valid and it's not needed anyway. All you need to do is to place the code in your test-uk.html page (or better still, rename the test-uk.html to index.html), if the language is set to es it should then load the page test-es.html otherwise it will continue to render the current page (which would be the test-uk.html)..

Let us know how you get on...

Comment #5

Good idea,.

I moved the script to the index.html and removed the second case statement..

However with little result. Just put your language on spanish and go to:.

Www.xcalak.info/index.html.

If you view the source you'll see the script but it won't go to.

Www.xcalak.info/es/index-es.html...

Comment #6

Actually if I view the source I.

Don't.

See the code. Are you sure you have uploaded the right index.html? I am clicking on the links in your previous posting...

Comment #7

I do see the script in the source!!!.

Perhaps you need to delete the old internet files?.

Hanno..

Comment #8

That was the first thing I did. Tried again and still couldn't view the source. The file may have been cached by my ISP. In which case I will need to wait for it to refresh..

I'll take a look this evening (UK time) as I am off to work now.

And that should give time for any caches to be flushed..

In the meantime can you display the.

Var tongue.

On the page so we can see that it is being set correctly?..

Comment #9

I am not farmiliar with scripting. Can you please explain to me how to do this (with prompt or...)...

Comment #10

Hanno,.

The code is missing..

I am looking at the page from a different PC connected to a different ISP, effectively this is the first time I am seeing your page and there is no way it can be cached..

Here is the output:.

Where is the language selection code?.

Try the attached file..

Comment #11

Torrent,.

The file you send is.

Www.xcalak.info/uk/welcome.html.

This file does not contain the script. The script is in.

Www.xcalak.info/index.html.

(from internet). It lloks like your example..

Hanno.

Index.html:.

<html>.

<head>.

<title>Xcalak Information Pages</title>.

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">.

</head>.

<script language="JavaScript">.

Var tongue = (navigator.language || navigator.userLanguage).

Tongue = tongue.substring(0,2) // just the first 2 chars.

Var newPage = "";.

Switch (tongue) {.

Case "es" : newPage = "/es/index-es.html";.

Break;.

}.

If (newPage) window.location.replace(newPage);.

</script>.

<frameset cols="150,*" frameborder="NO" border="0" framespacing="0" rows="*">.

<frame name="Navigation" scrolling="NO" src="uk/menu-uk.htm" frameborder="NO" noresize>.

<frame name="MainFrame" src="uk/welcome-uk.html" scrolling="AUTO" frameborder="NO">.

</frameset>.

<noframes>.

<body bgcolor="#FFFFFF" text="#000000">.

</body>.

</noframes>.

</html>..

Comment #12

Oh you've plced the code in a frameset..

Okay then try this..

Is now a good time to tell you that I'm not actually a whizz with javascript?..

Comment #13

Torrent.

I've tried your revised code. But it didn't work (dreamweaver got incredibly confused after I moved the index.html to the /uk/ directory and it took me quite some time to repair the code). After that I simplified the code because I don't think the frames etc are required..

I made to pages, you can try them:.

Index-test1.html;.

<html>.

<head>.

<title>Xcalak Information Pages</title>.

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">.

<script language="JavaScript">.

<!.

Function setLanguage(){.

Var tongue = (navigator.language || navigator.userLanguage).

Tongue = tongue.substring(0,2) // just the first 2 chars.

Var newPage = "index.html";.

Switch (tongue) {.

Case "es": newPage = "/es/index-es.html";.

Break;.

Case "en": newPage = "index.html";.

Break;.

}.

Return newPage;.

//>.

</script>.

</head>.

<body bgcolor="#FFFFFF" text="#000000">.

Index test 1.

</body>.

</html>.

And index-test2.html;.

<html>.

<head>.

<title>Xcalak Information Pages</title>.

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">.

<script language="JavaScript">.

<!.

Return "index.html";.

//>.

</script>.

</head>.

<body bgcolor="#FFFFFF" text="#000000">.

Index test 2.

</body>.

</html>.

I think the problem is in the 'return' statement because test 2 doesn't go to index.html.

Hanno..

Comment #14

Firstly, apologies, I have just noticed that I missed a closing } from my previous example..

I'm glad you ditched the frames, I'm not a fan of them anyway. You have a slight misunderstanding of what the return was supposed to do on the frames page but let's not worry about that now because you shouldn't need it anymore..

Here's what I think you should try. Take the main page for your site, the english one, and name it index.html. Into that page (in the <HEAD> section) insert the following code:.

Make sure your spanish page is located in /es/index-es.html then try it..

Let me know how you get on (you having fun yet?.

)..

Comment #15

Torrent,.

I agree with your aproch but were is the actual statement to go to the spanish index?.

Hanno..

Comment #16

Aha! You spotted my deliberate mistakge <ahem>.

You need to place the following line just before the </script> (after the } ).

If (newPage) window.location.replace(newPage);..

Comment #17

I have have added in the index.html. You can have a look at the source..

I revised the var newPage = "index-uk.html" to.

Var newPage = "" because the page would keep on on reloading and reloading all the time!.

Well it doesn't work. How can I show (prompt_ a variable in a window to check the variables..

Hanno..

Comment #18

Hanno,.

What I have noticed is that even by setting the browser's language setting it still reports to be "en-gb". I don't know why but you can see this yourself from the this code:.

What I did to check the code was to change the.

Case.

Statement to be.

En.

Just so I could test it does load the Spanish page, which it does. So the code is fine it's just a question of being able to make your browser report it is Spanish. The document.write functions are the ones which display the variable (change the case back to "es" otherwise it will just load the index-es.html and you won't see the language setting)...

Comment #19

You have to change the language setting in the Control Panel, not the browser...

Comment #20

Doh! Ok..

Anyway, if Hanno sets the.

Case.

Statement back to.

Es.

The code will work...

Comment #21

Yes it works!!!!.

It was long labour but finally it works. Who expected it to be this?.

Thanks Jon and Torrent!!.

Hanno..

Comment #22

Yeah, sorry it took so long but I'm not an expert in javascript myself. I just got interested in the problem..

Comment #23


This question was taken from a support group/message board and re-posted here so others can learn from it.