html >> Show layer when page loads

by ihsutd » Sat, 11 Feb 2006 03:56:57 GMT

Below code is for tabbed navigation. I want Tab 1 to show when the page is
loaded. Currently just the tabs appear and user has to click to see anything.



<script type="text/javascript">
function initShowHide() {
if (document.getElementById && document.getElementsByTagName &&
document.createTextNode) {
hide();
var toggle = document.getElementById('toggle');
var as = toggle.getElementsByTagName('a');
for (var i = 0; i < as.length; i++) {
as[i].onclick = function() {
show(this);
return false;
}
}

}
}

function show(s) {
hide();
var id = s.href.match(/#(\w.+)/)[1];
document.getElementById(id).style.display = 'block';
}

function hide() {
var toggleable =
document.getElementById('toggleable').getElementsByTagName('div');
for (var i = 0; i < toggleable.length; i++) {
toggleable[i].style.display = 'none';

}

}



window.onload = initShowHide;



</script>
<style type="text/css">


#tabsB {
width:100%;
font-size:93%;
line-height:normal;

}
#tabsB ul {
margin:0;
padding:2px 10px 1px 0px;
list-style:none;
}
#tabsB li {
display:inline;
margin:0;
padding:0;
}
#tabsB a {
float:left;
background:url("tableftB.gif") no-repeat left top;
margin:0;
padding:0 0 0 4px;
text-decoration:none;
}
#tabsB a span {
float:left;
display:block;
background:url("tabrightB.gif") no-repeat right top;
padding:5px 15px 4px 6px;
color:#666;
}
/* Commented Backslash Hack hides rule from IE5-Mac \*/
#tabsB a span {float:none;}
/* End IE5-Mac hack */
#tabsB a:hover span {
color:#000;
}
#tabsB a:hover {
background-position:0% -42px;
}
#tabsB a:hover span {
background-position:100% -42px;
}




</style>
</head>
<body>
<table width="50%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<tr>
<td><div id="tabsB">
<div align="left">
<ul id=toggle>
<li><a href="#1"><span>1 </span></a></li>
<li><a href="#2"><span>2</span></a></li>
<li><a href="#3"><span>3</span></a></li>
</ul>
</div>
</div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7" style="border-bottom:1px solid #CCCCCC;
border-left:1px solid #CCCCCC;border-right:1px solid #CCCCCC;"> 
<div id="toggleable">
<div id="1">Tab 2</div>
<div id="2">Tab 2</div>
<div id="3">Tab 3</div>
</div></td>
</tr>
</table>



Similar Threads

1. Show-Hide Layers showing on load

hey,

  have set up a page that has "show-hide layers" with buttons that control 
them.. all good and working so far. also i have set up the page that all but 
one is hidden onload but when the pages loads up (in various browsers) you can 
see the others loading too...

 is there anything i can do to prevent this?

2. Is the content of a hidden layer loaded when the page loads - Adobe Dreamweaver

3. loading different layers on page loads

hello,

 I was wondering if there was a way to load a layer on a page specific to a 
link on another page. for example -> I have 4 news topics on my home page. when 
you click on one i want the link to go to the news page and display the news 
layer specific to that news topic selected. is there any way of doing this? 
please let me know
 Thank you for your help
 Antoni

4. Close Div layer from the page loaded inside the layer - Ajax

5. Show/Hide layers with mpgs: not all load

6. Hiding/Showing controls w/ VBScript during Page Load. - ASP

7. Don't Show Page Until Loaded

Is there a HTML Code I can add so the webpage dosen't show before all content is loaded and ready?

8. Forgot how 2 show/hide on page load - Adobe Dreamweaver