Problem with javascript in web page.
- From: "BD" <none@xxxxxxxxxxx>
- Date: Sat, 13 Oct 2007 13:56:08 -0700
I'm can't get this to work the way I want it to.
I have divs that are hidden by using style="display:none"
I have this javascript function in the head
<script language="javascript">
function toggle(element)
{
if (document.layers)
{
current = (document.layers[element].display == 'none') ? 'block' : 'none';
document.layers[element].display = current;
}
else if (document.all)
{
current = (document.all[element].style.display == 'none') ? 'block' :
'none';
document.all[element].style.display = current;
}
else if (document.getElementById)
{
vista = (document.getElementById(element).style.display == 'none') ?
'block' : 'none';
document.getElementById(element).style.display = vista;
}
}
</script>
It works fine for toggleing the div but here comes the problem
The first line in the div is a bookmark. I want it to not only toggle the
div but I want it to behave the same as a normal call to a bookmark behaves
and that is by moving the div to the top of the page. The following call
won't do it.
<p class="links"><a onclick="toggle ('more');return false;"
href="#part2">Read More</a></p>
It toggles the div (more) OK but it does not move the bookmark (#part2) to
the top of the page
The same applies when hiding the div (more)
<p class="links"><a onclick="toggle ('more');return false;"
href="#top">Close this section</a></p>
This will toggle fine but it does not jump to the very top of the page
(bookmarked as top)
What am I doing wrong here.
Thanks
.
- Follow-Ups:
- Re: Problem with javascript in web page.
- From: David Mark
- Re: Problem with javascript in web page.
- Prev by Date: Re: How to sign Javascript - Unable to download the signing tool
- Next by Date: Re: Problem with javascript in web page.
- Previous by thread: Safer
- Next by thread: Re: Problem with javascript in web page.
- Index(es):
Relevant Pages
|