Firefox + Javascript unable to load page

I

iamaporkaholic

The main page of the site has this script which determines the
language settings of the OS. This works fine for IE but not for
firefox. Is there any other codes which i have to insert to make sure
Firefox would be able to load it?

<script type="text/javascript">
function detectlang()
{
var lang=navigator.userLanguage
var langs=navigator.systemLanguage
var langb=navigator.browserLanguage
if
((langs=="ar-sa"||lang=="ar-sa"||langb=="ar-sa"))
{window.location.reload("http://www.flynas.com/ara/index.html")}
else
{window.location.reload("http://www.flynas.com/eng/index.html")}
}
</script>
 
S

shimmyshack

The main page of the site has this script which determines the
language settings of the OS. This works fine for IE but not for
firefox. Is there any other codes which i have to insert to make sure
Firefox would be able to load it?

<script type="text/javascript">
function detectlang()
{
var lang=navigator.userLanguage
var langs=navigator.systemLanguage
var langb=navigator.browserLanguage
if
((langs=="ar-sa"||lang=="ar-sa"||langb=="ar-sa"))
{window.location.reload("http://www.flynas.com/ara/index.html")}
else
{window.location.reload("http://www.flynas.com/eng/index.html")}}

</script>

can't you use
Options +multiviews
if on Apache?
How will you send the correct charset header from the server for
xhtml?

It is by far the best option to use the server for this kind of thing,
unless you can't which is rare! Sending a 302 is not good for page
rank either.
By the way where was the user before the reload? Surely theres only
need to redirect away from a default.
 
A

ASM

(e-mail address removed) a écrit :
The main page of the site has this script which determines the
language settings of the OS. This works fine for IE but not for
firefox. Is there any other codes which i have to insert to make sure
Firefox would be able to load it?

In JavaScript the normal attributes for navigator are :

alert( ' appCodeName : ' +navigator.appCodeName+
'\n appName : ' +navigator.appName+
'\n appVersion : ' +navigator.appVersion+
'\n cookieEnabled : ' +navigator.cookieEnabled
'\n javaEnabled() : ' +navigator.javaEnabled()+
'\n language : ' +navigator.language+
'\n IE userLanguage : '+navigator.userLanguage+
'\n platform : ' +navigator.platform+
'\n userAgent : ' +navigator.userAgent;
<script type="text/javascript">
function detectlang()
{
var lang=navigator.userLanguage

var lang = navigator.language || navigator.userLanguage;
var langs=navigator.systemLanguage

doesn't exists (except IE ?)
var langb=navigator.browserLanguage

doesn't exists (except IE ?)
if
((langs=="ar-sa"||lang=="ar-sa"||langb=="ar-sa"))

or :
if(lang == 'ar-sa' || lang.substring(0,2) = 'ar')
 
I

iamaporkaholic

(e-mail address removed) a écrit :


In JavaScript the normal attributes for navigator are :

alert( ' appCodeName : ' +navigator.appCodeName+
'\n appName : ' +navigator.appName+
'\n appVersion : ' +navigator.appVersion+
'\n cookieEnabled : ' +navigator.cookieEnabled
'\n javaEnabled() : ' +navigator.javaEnabled()+
'\n language : ' +navigator.language+
'\n IE userLanguage : '+navigator.userLanguage+
'\n platform : ' +navigator.platform+
'\n userAgent : ' +navigator.userAgent;




var lang = navigator.language || navigator.userLanguage;


doesn't exists (except IE ?)


doesn't exists (except IE ?)


or :
if(lang == 'ar-sa' || lang.substring(0,2) = 'ar')

I did as suggested and remove navigator.browserLanguage &
navigator.systemLanguage from the script. It is still not working for
firefox. The same issue remains whereby the firefox browsers just keep
loading and doesn't redirect it to the actual site
 
S

shimmyshack

I did as suggested and remove navigator.browserLanguage &
navigator.systemLanguage from the script. It is still not working for
firefox. The same issue remains whereby the firefox browsers just keep
loading and doesn't redirect it to the actual site

there was a little extra code given to you which you have not used.
just try calling the following code lang.htm and run it in firefox,
there are sometimes 2 places where language preference will appear,
but mostly it is 3 places.

<script type="text/javascript">
alert( 'appCodeName : ' +navigator.appCodeName+
'\n appName : ' +navigator.appName+
'\n appVersion : ' +navigator.appVersion+
'\n cookieEnabled : ' +navigator.cookieEnabled+
'\n javaEnabled() : ' +navigator.javaEnabled()+
'\n language : ' +navigator.language+
'\n IE userLanguage : '+navigator.userLanguage+
'\n platform : ' +navigator.platform+
'\n userAgent : ' +navigator.userAgent
);
//also did you see
var lang = navigator.language || navigator.userLanguage;
alert(lang);
</script>
that should be enough for you.

BTW stick to using recognised country/language codes, so once you have
found one, dont then redirect to
ara or eng
but to
ar or en

or if you have dialects use en-GB or en-US etc... it will make your
life easier to follow standards, see what trouble IE caused you by
having its own windows specific way of doing things.
 

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,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top