On Fri, 27 Feb 2004 07:08:11 +0100, Ivo <no@thank.you> wrote:
"Sarah" <no***********@zhouse.com> wrote in message
news:9v********************************@4ax.com...
I have this function that shows or hides text on the page... and it
works great in IE... but I can't make it work in Mozilla type
browsers.. I tried reading up about different things to do... but
nothing I tried works... Can someone please help me?
<head>
<script language="JavaScript">
The language attribute should no longer be used. It is now recommended to
write <script type="text/javascript"> instead. Don't ask me why. And
don't ask the sites where you 've been reading either. They are at least
two years behind their schedule.
Two? Try six. That's how long language has been deprecated. :)
As for an explanation, read my post in reply to Erwin Moller's, "Use of
type and/or language in script-tag", posted 19 February. No-one trashed my
reasoning, so you might assume it's at least somewhat correct.
function toggleDisplay(objRef){
objRef.style.display = (objRef.style.display=="none") ? "" : "none";
}
</script>
</head>
<body>
<a href=javascript:toggleDisplay(text1)>Test</a>
Perhaps see <URL: http://jibbering.com/faq/#FAQ4_24>
Though that's a good place to start, the problem is with the use of
'text1'. Putting that fact that it's a bad identifier aside, the OP is
using it as a global variable. It is not - it's the id of a DIV.
The OP might want to try using:
function getRefById( id ) {
if( document.getElementById ) {
return document.getElementById( id );
} else if( document.all ) {
return document.all[ id ];
}
return null;
}
...
toggleDisplay( getRefById( 'text1' ))
Mike
--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)