Re: Problem with javascript in web page.
- From: "BD" <none@xxxxxxxxxxx>
- Date: Sat, 13 Oct 2007 16:33:26 -0700
Thanks David
I'll see what I can do with a few changes.
Are you saying that
<p class="links"><a onclick="toggle ('more');return false;"
href="#part2">Read More</a></p>
should be
<p class="links"><a onclick="toggle ('more')" href="#part2">Read
More</a></p>
Thanks for the help
"David Mark" <dmark.cinsoft@xxxxxxxxx> wrote in message
news:1192312728.298794.178550@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Oct 13, 4:56 pm, "BD" <n...@xxxxxxxxxxx> wrote:
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;
}
You can safely delete this first clause. If you really feel you must
try to support NS4, move this test to the end.
else if (document.all)
{
current = (document.all[element].style.display == 'none') ? 'block' :
'none';
document.all[element].style.display = current;
}
Similarly, this test should come after the test for
document.getElementById.
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.
Returning valse cancels the default action.
.
- Follow-Ups:
- Re: Problem with javascript in web page.
- From: Randy Webb
- Re: Problem with javascript in web page.
- References:
- Problem with javascript in web page.
- From: BD
- Re: Problem with javascript in web page.
- From: David Mark
- Problem with javascript in web page.
- Prev by Date: Re: Dynamically modify CSS
- Next by Date: Re: How to optimize this JavaScript?
- Previous by thread: Re: Problem with javascript in web page.
- Next by thread: Re: Problem with javascript in web page.
- Index(es):
Relevant Pages
|