By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,299 Members | 1,415 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,299 IT Pros & Developers. It's quick & easy.

show layer onload

P: n/a
BGT
Hi

I have some layers, at the same position.
I want to show one of them according to the system language,
and I have made this so far:

function showit() {
if (lang == "da") document.da.visibility="show"
if (lang == "de") document.de.visibility="show"
if (lang == "it") document.it.visibility="show"
if (lang == "fr") document.fr.visibility="show"
.................

<div class="box" id="da" style="visibility: hidden; position:
absolute; top: 1500px; align: center;">
<div class="box" id="de" style="visibility: hidden; position:
absolute; top: 1500px; align: center;">
..... and so on .......

body onload showit()

But it get: 'document.da' is null or not an object

What do I do wrong ?

Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
BGT wrote:
Hi

I have some layers, at the same position.
I want to show one of them according to the system language,
How are you determining system language?
and I have made this so far:

function showit() {
if (lang == "da") document.da.visibility="show"
if (lang == "de") document.de.visibility="show"
if (lang == "it") document.it.visibility="show"
if (lang == "fr") document.fr.visibility="show"
.................
document.getElementById('da').style.visibility = "visible";
And, where is lang defined?
<div class="box" id="da" style="visibility: hidden; position:
absolute; top: 1500px; align: center;">
<div class="box" id="de" style="visibility: hidden; position:
absolute; top: 1500px; align: center;">
..... and so on .......
If your visitors have JS disabled, they will see nothing. This whole
project is better suited to be done on the server, or, to have static
links on an intro page to each language page.
body onload showit()

But it get: 'document.da' is null or not an object


What browser?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #2

P: n/a
Then why are we here discussing javascript at all if a very small percentage
of users have it turned off?

Have we not heard of "MAJORITY RULES"?
I've seen a vast majority of sites using some form of JS.

If you were to go to the country of Greece, you would expect everyone there
to know and understand English.

Why can't you just assist someone without the negativism all the time?
Jul 23 '05 #3

P: n/a
BGT
On Sun, 23 Jan 2005 19:48:52 -0500, Randy Webb
<Hi************@aol.com> wrote:
I want to show one of them according to the system language,
How are you determining system language?

that is no problem, works perfect on all other pages.
document.getElementById('da').style.visibility = "visible";
And, where is lang defined? lang is defined in another extern script.
If your visitors have JS disabled, they will see nothing. This whole
project is better suited to be done on the server, or, to have static
links on an intro page to each language page.

Less than 1% of my visitors has js disabled,
if js was a problem this group would probably not exist :)
But it get: 'document.da' is null or not an object

What browser?

IE6

Jul 23 '05 #4

P: n/a
BGT wrote:
I have some layers, at the same position.
I want to show one of them according to the system language,
and I have made this so far:

function showit() {
if (lang == "da") document.da.visibility="show"
if (lang == "de") document.de.visibility="show"
if (lang == "it") document.it.visibility="show"
if (lang == "fr") document.fr.visibility="show"
.................

<div class="box" id="da" style="visibility: hidden; position:
absolute; top: 1500px; align: center;">
<div class="box" id="de" style="visibility: hidden; position:
absolute; top: 1500px; align: center;">
..... and so on .......

body onload showit()

But it get: 'document.da' is null or not an object

What do I do wrong ?


A better way to do this would be to set a class on your body tag (or
another tag enclosing all of the language specific sections). So for
example, your HTML could contain:

<body class="language-en">

showit can modify the body class, and you then use css to control the
visibility of whatever sections you want:

function showit() {
document.body.className = "language-"+lang;
}

You may need to add some checking code if there is any chance lang is set
to something unexpected.

Also, you should move the position and alignment out of style attributes
and into a stylesheet.
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.