You are here: Script not behaving as needed « HTML « IT news, forums, messages
Script not behaving as needed

Posted by SHC on 10/12/92 11:57

I've put together the script below to show and hide content when an
image is clicked. However, when it is clicked the screen jumps to the
top of the page, rather than remaining with the image. Can anyone help
please.
Thanks
SHC


<html>
<head>
<script language="JavaScript">
function showAndHide(theId)
{
var el = document.getElementById(theId)

if (el.style.display=="none")
{
el.style.display="block"; //show element
}
else
{
el.style.display="none"; //hide element
}
}
</script>
</head>

<body>
<table><tr><td width=790 height="1000" valign="top">Some
Content</td></tr></table>
<table><tr>
<td valign="top">
<a href="#" onClick = showAndHide('Title')><img
src="graphics/picture_heading.gif" alt="Picture Heading" height=30
width=400 border="0"></a>
<div id='Title' style="display:none">
<p>Text</p></div></td></tr>
</table>
</body>
</html>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация