473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Showing and Hiding

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">

function toggleDisplay(objRef){
objRef.style.display = (objRef.style.display=="none") ? "" : "none";
}

</script>
</head>
<body>

<a href=javascript:toggleDisplay(text1)>Test</a>

<div id="text1" style="display: none;">
here is some text....
</div>

</body>
Thanks for any help you can give me!!!

-Sarah
Jul 20 '05 #1
5 1739
Ivo
"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.
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>

HTH
Ivo
Jul 20 '05 #2
>
Perhaps see <URL: http://jibbering.com/faq/#FAQ4_24>

HTH
Ivo

Thanks.... That's very helpful... Do you happen to have a FAQ that
actually answers my question? :)
Jul 20 '05 #3
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)
Jul 20 '05 #4
> 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">

function toggleDisplay(objRef){
objRef.style.display = (objRef.style.display=="none") ? "" : "none";
}

</script>
</head>
<body>

<a href=javascript:toggleDisplay(text1)>Test</a>

<div id="text1" style="display: none;">
here is some text....
</div>

</body>


Watch the line-wrapping but this works in NN7 and IE5.5 ...
<html>
<head>
<script language="JavaScript">
function toggleDisplay(objId){
document.getElementById(objId).style.display =
(document.getElementById(objId).style.display=="no ne") ? "" : "none";
}
</script>
</head>
<body>
<a href=javascript:toggleDisplay('text1')>Test</a>
<div id="text1" style="display: none;">
here is some text....
</div>
</body>
</html>
Jul 20 '05 #5
Thank you very much for helping me Robert... that works great...

Best wishes,

-Sarah

Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dré | last post by:
Hi, I'm making a FAQ-page. To keep it a little synoptic, only the questions are visible. When you klick on a certain question, the answer appears. You can find an example at:...
2
by: c.anandkumar | last post by:
Hi All - I have some problems getting a small piece of javascript working correctly for Firefox. Here is what I am trying to do - 1. I have a form (like a search form) 2. I have many groups...
5
by: gregmercer | last post by:
I have the following html sample, where I'd like to have a show and hide two divs, one replacing the other. Following these two divs is a third div (the bluediv) which I would like to have placed...
2
by: EventListener | last post by:
I have a folder/file tree that is dynamically generated from an xml file. The way I've written it seems to work. Since I'm a fairly novice javascript programmer, I'm concerned that there may be a...
1
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems...
7
by: Mike9900 | last post by:
I am inheriting from a text box control and does not want the client see some of the methods be invisible to the clients. Mike
1
by: Anony | last post by:
Is it possible to hide and show widgets while the window is open?
2
by: =?Utf-8?B?Sm9zaCBTY2htaWR0?= | last post by:
I have a gridview that is being used for managing inventory. The default view shows the stock currently available. When editing I don't want the stock to be directly edited, rather the user will...
1
by: Grimm | last post by:
I am developing an internalk inteface that integrates alot of seperate tools into one interface. The current version uses one Iframe inside a div layer for positioning. Currently the seperate web...
17
by: rohitchawla | last post by:
i am trying to show and hide a div when onmouseover and onmouseover another div element. i am setting a setTimeout duration on onmouseout to delay the hiding of div for around two second The...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.