a cry for (javascript) help
I don’t know Javascript.
That said, I’m trying to implement the recent ALA technique to split up some long pages into chunks. Whether this is a good idea or not, I can’t decide, but I’m going to do it for my udp site for a particularly long publication that requires three levels of navigation. The site as it is set up really doesn’t allow three levels very well, so I want to do something like this to allow access to the sections.
The problem is that I don’t know what I’m doing. I can figure out well enough how to modify the script as is on the site. But, I have a div class = “photo” that nees to show up, and the script as it is hides the photo div, because it’s a class and not and id. The script basically hides everything that isn’t div id = (specified in the loop in the script).
Read more if you dare…
function hideDivs(exempt)
{
if (!document.getElementsByTagName) {
return null;
}
if (!exempt) exempt = "";
var divs =
document.getElementsByTagName("div");
for(var i=0; i < divs.length; i++)
{
var div = divs[i];
var id = div.id;
if ((id != "everything") &&
(id != "topHeader") &&
(id != "mainNavigation") &&
(id != "mainContent") &&
(id != "sideLogo") &&
(id != "story") &&
(id != "tabNavigation") &&
(id != "menu") &&
(id != "footer") &&
(id != exempt))
{
div.style.display = "none";
}
}
}
This works, but hides div class=”photo”. How can I modify this loop to allow the class photo to show up?
Thanks for indulging me, I promise this site isn’t going to turn into a “help me with my code” fest.
PS: the rest of the javascript file is included below, in case it’s helpful.
function fixLinks()
{
if (!document.getElementsByTagName) {
return null;
}
var anchors =
document.getElementsByTagName("a");
for(var i=0; i < anchors.length; i++)
{
var a = anchors[i];
var href = a.href;
if ((href.indexOf("#") != -1) &&
(href.indexOf("tabNavigation") == -1))
{
var index = href.indexOf("#") + 1;
href = "javascript:show('" +
href.substring(index) + "');";
a.setAttribute("href",href);
}
}
}
function sendFocus(what)
{
var obj = document.getElementById(what);
obj.focus();
}
function show(what)
{
if (!document.getElementById) {
return null;
}
showWhat =
document.getElementById(what);
showWhat.style.display = "block";
hideDivs(what);
}
window.onload = function()
{
hideDivs("initial");
fixLinks();
sendFocus("cultureTab");
}
5 Comments
No comments yet.
RSS feed for comments on this post.
Sorry, the comment form is closed at this time.
