473,396 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

show/hide layers onLoad

Hi

I'm looking for a javascript with the following operation:

if history.length <=2
show "layer1" and hide "layer2"

else
hide "layer1' and show "layer2"

Notes
"layer1" and "layer2" are the IDs of two layers
this should be in a function, in order to call it with onLoad

Can someone help me please?

--
Merlin dying to the Lady of the Lake:
"We lived our lives with passion and devotion"
--
Please remove slashes to contact me
Jul 23 '05 #1
2 3979

geotso <kata/ye/xi@yahoo.gr> wrote in message news
:cs**********@usenet.otenet.gr...
Hi

I'm looking for a javascript with the following operation:

if history.length <=2
show "layer1" and hide "layer2"

else
hide "layer1' and show "layer2"

Notes
"layer1" and "layer2" are the IDs of two layers
this should be in a function, in order to call it with onLoad

Can someone help me please?


history.length is treated inconsistently across browsers.

Assuming both layers are initially styled as hidden.

Call with: <body onload='showLayer("layer1","layer2")'>

function showLayer(L1, L2)
{
var ref=null;
if( document.getElementById && (ref=document.get
ElementById(history.length<=2 ? L1 : L2)) )
ref.style.visibility='visible';
}

--
S.C.

Jul 23 '05 #2
Stephen Chalmers wrote:
geotso <kata/ye/xi@yahoo.gr> wrote in message news
cs**********@usenet.otenet.gr...
Hi

I'm looking for a javascript with the following operation:

if history.length <=2
show "layer1" and hide "layer2"

else
hide "layer1' and show "layer2"

Notes
"layer1" and "layer2" are the IDs of two layers
this should be in a function, in order to call it with onLoad

Can someone help me please?


history.length is treated inconsistently across browsers.

Assuming both layers are initially styled as hidden.

Call with: <body onload='showLayer("layer1","layer2")'>

function showLayer(L1, L2)
{
var ref=null;
if( document.getElementById && (ref=document.get
ElementById(history.length<=2 ? L1 : L2)) )
ref.style.visibility='visible';
}


It works like a charm!

(a small change, just for the records:
I've used style="display:none" and then .style.display=''; instead of
style="visibility:hidden" and .style.visibility='visible'.
This way, I prevent browser's window from displaying the vertical scrollbar
if anyone of the layers is too short to need it).

Thank you very much!!
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: David | last post by:
Hi everyone, Hoping there are some .js/browser experts out there that can help with this weird problem. I have made a swap div routine and applied the events to menu buttons with a closer...
2
by: MOHSEN KASHANI | last post by:
Hi, I am trying to hide some form elements in a form by default and show/hide depending on which radio button is clicked. This is what I have but it is not working: <head> <style> ..noshow {...
4
by: jerryyang_la1 | last post by:
I've found this script that allows be to hide/show form elements.. <script language="JavaScript"><!-- var toggle = true; function show(object) { if (document.layers && document.layers)...
3
by: Merlin | last post by:
Hi there, I am trying to create a form with an dynamic field that can be shown or hidden. As I saw for example on google it is possible with JS to show a layer and move the content underneath...
1
by: asilverpeach | last post by:
Hey Guys! Found some great scripts here on this topic but have to make to changes to the code that I can't seem to figure out. First, In the following code clicking on the headers shows the...
1
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. ...
3
by: safiratec | last post by:
Hi, I want to show a div depending of the value of a <select> option, using 2 functions hidediv() and showdiv() - it is working fine in firefox, but not in IE (tested with IE 6 and 7). <body...
1
oranoos3000
by: oranoos3000 | last post by:
hi would you please help me i have a online shopping center that i show pictures of the my product in home page. in the InterExplorer pictures is shown correctly but in Firefox browser is shown...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.