[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

JavaScript and browser differences for showing/hiding divs

Posted on 2004-09-10
5
Medium Priority
?
290 Views
Last Modified: 2008-05-21
I am having browser issues with a function that is supposed to show one div and hide another.  After the page loads, they are supposed to switch so that the previously visible div is hidden and the previously hidden div is visible.  This works great in IE, but in Netscape both divs are shown all the time.  In Safari, only the content div shows.  I would like for this to behave properly in all major browsers if at all possible.  
Here's the function:

<script type="text/javascript">
  <!--
    function showMessage() {
      if(document.all){
                //browser="ie"
            document.all.MessageDiv.style.visibility = "visible";
            document.all.ContentDiv.style.visibility = "hidden";
            }
      else if(document.layers){
      //browser="NN4";
            document.MessageDiv.visibility = "show";
            document.ContentDiv.visibility = "hide";
            }
      else if(!document.all && document.getElementById){
                //browser="NN6";
            document.getElementByID("MessageDiv").style.visibility = "visible";
            document.getElementByID("ContentDiv").style.visibility = "hidden";
            }
      }
      -->
</script>

This function is just for showing the message/hiding the content.  At the end of the page I then switch them.  The rest of the page is asp/html.  I don't know JavaScript well at all and don't usually use it, but I didn't know of another way to do this.  Any assistance would be greatly appreciated.
0
Comment
Question by:mjholden
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 10

Expert Comment

by:rockmansattic
ID: 12027901
I would consider placing this question in the Javascript section, possibly just a 20pt link.

Good Luck
Rockman
0
 
LVL 27

Accepted Solution

by:
Asta Cu earned 1200 total points
ID: 12028070
The thing is that IE and NS implement JavaScript somewhat differently as a result of variations in the Document Object Model as well as in other aspects. That is further complicated by varying versions installed; here's one sampling from our PAQ database:
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20611570.html?query=div+netscape+javascript&clearTAFilter=true
0
 

Author Comment

by:mjholden
ID: 12028158
Thank you both for your comments.  I'll try out some of the suggestions from the post mentioned.

Is there any (relatively easy) way to do what I want without JavaScript?
0
 

Author Comment

by:mjholden
ID: 12029664
Thank you astaec!  The post you suggested contained code that was very close to what I needed, so I was able to fix the problem.
0
 
LVL 27

Expert Comment

by:Asta Cu
ID: 12031772
YAY!  I'm so pleased.  Thank you for the good news and the fine grade.  I'm happy I could help you.
Best wishes,
":0) Asta
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently found myself in a Corporate Situation where the client had requested blocking access to any and all websites except his own Domain? Easy? I am sure this would be your answer but their requirement was, this has to be done without using…
Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question