473,782 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

display inherit and none switching in js with ie7

Hi all

This js i wrote to switch display on and off of a given element does
not work in ie but it does in ff and safari.

how can i make it work with ie guys?
<script type='text/javascript'>
function switch_display( switchme) {

curr_el = document.getEle mentById(switch me);
curr_dis = curr_el.style.d isplay;

if (curr_dis != 'none') {
hidethis(curr_e l);
}
if (curr_dis == 'none') {
showthis(curr_e l);
}

return;

}

function hidethis(curr_e l) {
curr_el.style.d isplay = 'none';
}

function showthis(curr_e l) {
curr_el.style.d isplay = 'inherit';
}
</script>

<input type="button" onClick="switch _display('testd iv');" value="button
to switch display">

<div id="testdiv">so me text
</div>

Jan 3 '07 #1
7 6770
>
This js i wrote to switch display on and off of a given element does
not work in ie but it does in ff and safari.

i should probably be more explicit, by 'does not work in ie' i mean it
will hide hidden text but will not display it again when u re-click the
button

Jan 3 '07 #2
libsfan01 said the following on 1/3/2007 11:22 AM:
>This js i wrote to switch display on and off of a given element does
not work in ie but it does in ff and safari.


i should probably be more explicit, by 'does not work in ie' i mean it
will hide hidden text but will not display it again when u re-click the
button
display:visible
display:hidden

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 3 '07 #3
Randy Webb wrote:
libsfan01 said the following on 1/3/2007 11:22 AM:
>>This js i wrote to switch display on and off of a given
element does not work in ie but it does in ff and safari.

i should probably be more explicit, by 'does not work in ie'
i mean it will hide hidden text but will not display it
again when u re-click the button

display:visible
display:hidden
The permissible values of the CSS display property (as defined in the
CSS 2.0 spec) are:- inline | block | list-item | run-in | compact |
marker | table | inline-table | table-row-group | table-header-group |
table-footer-group | table-row | table-column-group | table-column |
table-cell | table-caption | none | inherit

I am not sure why 'inherit' appears in that list as the property index
(appendix F) states that the property is not inherited.

Richard.
Jan 4 '07 #4
"Richard Cornford" <Ri*****@litote s.demon.co.ukwr ote:
>The permissible values of the CSS display property (as defined in the
CSS 2.0 spec) are:- inline | block | list-item | run-in | compact |
marker | table | inline-table | table-row-group | table-header-group |
table-footer-group | table-row | table-column-group | table-column |
table-cell | table-caption | none | inherit
Despite the fact that officially the 2.0 spec is the only CSS2.x spec
with Rec status, for practical web authoring CSS2.0 should be considered
obsolete and of historical relevance only. Authors should consult the
CSS2.1 Draft instead.
>I am not sure why 'inherit' appears in that list as the property index
(appendix F) states that the property is not inherited.
Not by default, but it can be if explicitly specified.
http://www.w3.org/TR/CSS21/cascade.h...ue-def-inherit

--
Spartanicus
Jan 4 '07 #5

libsfan01 wrote:
Hi all

This js i wrote to switch display on and off of a given element does
not work in ie but it does in ff and safari.

how can i make it work with ie guys?
<script type='text/javascript'>
function switch_display( switchme) {

curr_el = document.getEle mentById(switch me);
curr_dis = curr_el.style.d isplay;

if (curr_dis != 'none') {
hidethis(curr_e l);
}
if (curr_dis == 'none') {
showthis(curr_e l);
}

return;

}
Display toggle functions are usually written something like:

function switch_display( switchme) {
var el = document.getEle mentById(switch me);
el.style.displa y = (el.style.displ ay == 'none')? '' : 'none';
}

Don't forget feature detection.
--
Rob

Jan 4 '07 #6
Display toggle functions are usually written something like:
>
function switch_display( switchme) {
var el = document.getEle mentById(switch me);
el.style.displa y = (el.style.displ ay == 'none')? '' : 'none';
}
Thanks Rob that works great. can anyone explain to me how this line of
code works:

el.style.displa y = (el.style.displ ay == 'none')? '' : 'none';

what do the ? and : characters do, does it work something like, if
display equals 'none' then display becomes '' and if display = '' then
display becomes 'none'

are there any good online resources on this type of control structure?

thanks again :-)

marc

Jan 5 '07 #7
libsfan01 wrote:
>Display toggle functions are usually written something like:

function switch_display( switchme) {
var el = document.getEle mentById(switch me);
el.style.displa y = (el.style.displ ay == 'none')? '' : 'none';
}

Thanks Rob that works great. can anyone explain to me how this line of
code works:

el.style.displa y = (el.style.displ ay == 'none')? '' : 'none';

what do the ? and : characters do, does it work something like, if
display equals 'none' then display becomes '' and if display = '' then
display becomes 'none'
Yes, its the conditional operator:

<URL:
http://developer.mozilla.org/en/docs...ional_operator
>
and is a shortcut way of writing:

if (el.style.displ ay == 'none') {
el.style.displa y = '';
} else {
el.style.displa y = 'none';
}

are there any good online resources on this type of control structure?
The FAQ lists a good selection of javascript resources (including the
Core JavaScript 1.5 Guide referenced above):

<URL: http://www.jibbering.com/faq/#FAQ3_2 >
--
Rob
Jan 5 '07 #8

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

Similar topics

13
40766
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div style="display:none"> can be displayed by setting the style attribute to "display:", or hidden with "display:none". This gives the illusion that the person filling out the form is switching from page to page...without the overhead of extra hits on the server,...
1
5425
by: Jon W | last post by:
This is a small table with hover on the table cells. The first cell is setup to switch from div element to input element by use of display:block/none. In IE, onclick the input element is displayed correctly but it disappears if another hover is triggered. Any thoughts? Thanks,Jonny <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
5
1524
by: scott | last post by:
I'm trying to display a small "color square" to the left of each combo box choice. I know I can make each choice have a different background color, but is it possible to display a background image for each row? In my code below, I'm trying to display img_color1.gif which is a 5 pixel wide by 10 pixel high transparent gif with a small color square on the background of a choice. My end goal is to have an Outlook looking combo box like the...
0
5830
by: Jon W | last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"> <html> <head> <title>rolly</title> <!-- The desired performance for this gem would be to: 1. click on table cells 2. edit in INPUT 3. click away, data presented in table cell. 2.0 The table cells have hover highlighting.
15
12493
by: Markus Ernst | last post by:
Hi When toggling an element on and off by setting its display property via DOM access, display:none is valid for all kinds of elements, but I can't find anything about a generic value for toggling on again. Furthermore, UAs do not recognize the same values. To make a table row visible, IE wants display:block while FF wants display:table-row. Am I missing something? I am looking for something like display:normal
4
2367
by: DoomedLung | last post by:
I have been developing an image gallery which needed to be dynamic as possible. so I have placed the gallery in a div plus a div containing the large image to be displayed. It works by changing the display property of the gallery div to 'none' and the largeImage div to 'block' which has an affect of switching pages but obviously saving time developing a single page for each large Image, but (cliche') when I refresh the page the with the...
3
2278
by: DoomedLung | last post by:
I have been developing an image gallery which needed to be dynamic as possible. so I have placed the gallery in a div plus a div containing the large image to be displayed. It works by changing the display property of the gallery div to 'none' and the largeImage div to 'block' which has an affect of switching pages but obviously saving time developing a single page for each large Image, but (cliche') when I refresh the page with the...
7
4069
by: khinester | last post by:
Hello, I have the following template that basically does the following: User select Country, then a sub-list is generated with Regions and then this returns the Counties ############### <tr> <td colspan="2">
19
2341
by: Samuel Murray | last post by:
G'day everyone I'm trying to find out if there is a way (perhaps using CSS) to let this code: <table><tr><td>One Two Three</td></tr></table> display the same as if the code would have been:
0
9641
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.